Replace Line in config file - regex

I want to replace lines of the Redmine config file automatically. The config file looks like this:
# MySQL (default setup).
....
production:
adapter: mysql
database: redmine
host: localhost
username: root
password:
encoding: utf8
development:
adapter: mysql
database: redmine_development
host: localhost
username: root
password:
encoding: utf8
....
I only want to replace lines after the production section like password, database,...
How can I do that with sed?

based on your example file:
sed -r '/^production:/,/^$/{s/(\s*database:).*/\1newDB/;
s/(\s*password:).*/\1newPWD/}' yourConfig
the above cmd will change "database" and "password" setting in "production" section to newDB and newPWD.
output:
...
production:
adapter: mysql
database:newDB
host: localhost
username: root
password:newPWD
encoding: utf8
development:
adapter: mysql
database: redmine_development
host: localhost
username: root
password:
encoding: utf8
...

Related

Redmine Office 365 Email Configuration Error

This is the config/configuration.yml file I use:
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
enable_starttls_auto: true
address: "smtp.office365.com"
port: 587
domain: "smtp.office365.com"
authentication: :login
user_name: "xxx#xxx"
password: "xxx"
when I send test mail in Redmine, it results to this error:
vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.4.2/lib/action_dispatch/middleware/cookies.rb:649:in `commit'
vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.4.2/lib/action_dispatch/middleware/cookies.rb:484:in `[]='
vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.4.2/lib/action_dispatch/middleware/session/cookie_store.rb:116:in `set_cookie'
vendor/bundle/ruby/2.5.0/gems/rack-2.2.2/lib/rack/session/abstract/id.rb:403:in `commit_session'
/usr/local/rvm/gems/ruby-2.5.3/gems/passenger-6.0.4/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
/usr/local/rvm/gems/ruby-2.5.3/gems/passenger-6.0.4/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:157:in `accept_and_process_next_request'
What can I do to prevent this problem?

Generate Entities in Symfony with two DB connections

I have a project with 2 DB connections (default and routeone). My config is like this:
dbal:
default_connection: routeone
types:
point: ACME\Infrastructure\Resources\Types\PointType
connections:
default:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
routeone:
driver: pdo_mysql
host: "%database_routeone_host%"
port: "%database_routeone_port%"
dbname: "%database_routeone_name%"
user: "%database_routeone_user%"
password: "%database_routeone_password%"
charset: UTF8
mapping_types:
enum: string
point: point
orm:
default_entity_manager: routeone
auto_generate_proxy_classes: "%kernel.debug%"
entity_managers:
default:
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
ACME:
type: yml
dir: '%kernel.root_dir%/../src/ACME/Infrastructure/Resources/doctrine'
is_bundle: false
prefix: ACME\Domain\Entity
alias: ACME
routeone:
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: false
mappings:
RouteOne:
type: yml
dir: '%kernel.root_dir%/../src/ACME/Infrastructure/Resources/doctrine/RouteOne'
is_bundle: false
prefix: RouteOne
alias: RouteOne
I have the control of the default connection, but no the routeone. I cannot change the structure of the existing DB in routeone.
When I generate the YML configuration files with this this command (NB I have put momentarily the routeone connection as a default):
php bin/console doctrine:mapping:convert yml ./src/ACME/Infrastructure/Resources/doctrine/Routeone/ --from-database
This generate a files in this path like that: AclClass.orm.yml
AclClass:
type: entity
table: acl_class
....
But when I want to generate Entities Class with this command:
php bin/console doctrine:generate:entities src/ACME/Infrastructure/Resources/doctrine/RouteOne/ --path=src/ACME/Domain/Entity/RouteOne/
Prompt this error:
[Doctrine\Common\Persistence\Mapping\MappingException]
No mapping file found named 'AclClass.orm.yml' for class 'ACME\Domain\Entity\RouteOne\AclClass'.
What I'm doing wrong?

Redmine Email Configuration - An error occurred while sending mail (530 5.7.0 Authentication required )

My configuration.yml looks like this
default:
configuration
email_delivery:
delivery_method: :smtp
smtp_settings:
address: "mail.example.com"
port: 25
domain: "example.com"
authentication: :login
user_name: "redmine#example.com"
password: "xxxxxxxx"
I am getting the message An error occurred while sending mail (530 5.7.0 Authentication required ) while treying to send a test mail.
I have tried out different options with starttls, removing.adding quotes. It does not work. The configuration details work fine with Thunderbird. Somehow it does not work here.
Please note my redmine setup is on AWS and my mail server is on another shared hosting. Does it has anything to do with the security groups?
Please guide me fix the issue. Thanks in adavance.
You need to change default to production or development, and configuration line is too much so your config would look like this:
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: "mail.example.com"
port: 25
domain: "example.com"
authentication: :login
user_name: "redmine#example.com"
password: "xxxxxxxx"

how to install bootstrap in symfony2?

I installed bootstrap through this link
But when I run
php app/console server:run
To check if it is working it returns an error.
The error is
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Invalid configuration for path "assetic.filters.file":
The assetic.filters
config "C:/wamp/www/bootstrap/app/../vendor/leafo/lessphp/lessc.in
c.php" must be either null or an array.
How to remove this exception?
here is my config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
#translator: { fallback: %locale% }
secret: %secret%
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: %kernel.debug%
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_proxies: ~
session: ~
fragments: ~
# Twig Configuration
twig:
form:
resources:
- "AcmeBundle:Form:form_div_layout.html.twig"
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
lessphp:
file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
apply_to: "\.less$"
cssrewrite: ~
#closure:
# jar: %kernel.root_dir%/Resources/java/compiler.jar
#yui_css:
# jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
bc_bootstrap:
assets_dir: %kernel.root_dir%/../vendor/twitter/bootstrap
jquery_path: %kernel.root_dir%/../vendor/jquery/jquery/jquery-1.9.1.js
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: %kernel.root_dir%/data/data.db3
# path: %database_path%
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
spool: { type: memory }
The indentation is important in yml files.
file and apply_to should be with 4 more spaces.

error in redmine email notification via gmail

I setup redmine on Ubuntu 10.04.2
here is my email.yml:
# Outgoing email settings
production:
delivery_method: :smtp
smtp_settings:
tls:true
enable_starttls_auto: true
address: "smtp.gmail.com"
port: "587"
domain: "smtp.gmail.com"
authentication: :plain
user_name: "******#gmail.com"
password: "*****"
development:
delivery_method: :smtp
smtp_settings:
tls:true
address: "smtp.gmail.com"
port: "587"
domain: "smtp.gmail.com"
authentication: :plain
user_name: "******#gmail.com"
password: "*****"
I start the redmine server as root,login redmine with admin
then Administration>Settings>Email notifications
and then I send the test mail by clicking the link at bottom
But i got this:
An error occurred while sending mail (getaddrinfo: Name or service not known)
is there anyone who send email successfully via gmail?and please give me some suggestion
thanks advance!
-----------append1----------------
I copy the "production:" in the config/email.yml to "# ==== SMTP server at using TLS (GMail)production:" in the /etc/redmine/default/configuration.yml
and also modify the "# default configuration options for all environments" in buttom of configuration.yml
It works!
[CLOSED]