-
Notifications
You must be signed in to change notification settings - Fork 0
add options in base install #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
4d2e583
e23f470
6e09c94
d38e638
843a9fc
7a554ca
2feae5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,76 +1,100 @@ | ||
| #!/bin/bash | ||
| set -eu | ||
|
|
||
| user=deployer | ||
| mawidabp_path=/var/www/mawidabp.com | ||
| dir=$(cd "$(dirname "$0")" && pwd) | ||
| dir_conf=$dir/config_files | ||
| dir_templates=$dir/templates | ||
| dir_services=$dir/services | ||
| dir_nginx=/etc/nginx | ||
|
|
||
| while getopts u:p: option | ||
| do | ||
| case "${option}" in | ||
| u) user=${OPTARG};; | ||
| p) mawidabp_path=${OPTARG};; | ||
| :) echo "INVALID";; | ||
| \?) echo "Argumento -${option} erroneo use: | ||
| [u] Nombre de usuario | ||
| [p] Directorio de instalacion | ||
| " | ||
| exit;; | ||
|
|
||
| esac | ||
| done | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esto se suele poner así: while getopts u:p: option; do
case $option in
esac
doneY el :) se le pone el mensaje "requiere un argumento". También se pone en eso dos casos un exit 1, así indicás error. |
||
| shift $((OPTIND -1)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ¿Para qué hiciste esto? |
||
|
|
||
| #Create config files | ||
| eval "echo \"$(cat $dir_templates/nginx.conf)\" > $dir_conf/nging.conf" | ||
| eval "echo \"$(cat $dir_templates/mawidabp.com)\" > $dir_conf/mawidabp.com" | ||
| eval "echo \"$(cat $dir_templates/sudoers)\" > $dir_conf/sudoers" | ||
| eval "echo \"$(cat $dir_templates/sidekiq.service)\" > $dir_services/sidekiq.service" | ||
| eval "echo \"$(cat $dir_templates/unicorn.service)\" > $dir_services/unicorn.service" | ||
|
|
||
| #URLS | ||
| repo_nginx=http://nginx.org/packages/centos/7/x86_64/RPMS | ||
| repo_redis_ib01=https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/j | ||
| repo_redis=https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/r | ||
| repo_node=https://rpm.nodesource.com/pub_14.x/el/7/x86_64 | ||
|
|
||
| dir=$(cd "$(dirname "$0")" && pwd) | ||
| dir_conf=$dir/config_files | ||
| dir_services=$dir/services | ||
| dir_nginx=/etc/nginx | ||
|
|
||
| echo "Instalación Paquete NGINX" | ||
| #echo "Instalación Paquete NGINX" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Todos estos echo comentados, los pasaría a comentarios normales y en inglés. |
||
| rpm -ivh $repo_nginx/nginx-1.18.0-1.el7.ngx.x86_64.rpm | ||
|
|
||
| echo creamos directorios sites | ||
| #echo creamos directorios sites | ||
| mkdir -p /etc/nginx/sites-available | ||
| mkdir -p /etc/nginx/sites-enabled | ||
|
|
||
| echo "Arrancamos y habilitamos nginx" | ||
| #echo "Arrancamos y habilitamos nginx" | ||
| systemctl start nginx | ||
| systemctl enable nginx | ||
|
|
||
|
|
||
| echo "Copiamos archivo de configuración Nginx" | ||
| #echo "Copiamos archivo de configuración Nginx" | ||
| /bin/cat $dir_conf/nginx.conf > $dir_nginx/nginx.conf | ||
| cp $dir_conf/mawidabp.com $dir_nginx/sites-available/ | ||
|
|
||
| echo "Creamos enlace simbolico" | ||
| #echo "Creamos enlace simbolico" | ||
| ln -s $dir_nginx/sites-available/mawidabp.com $dir_nginx/sites-enabled/mawidabp.com | ||
|
|
||
| echo "Recargamos nginx" | ||
| #echo "Recargamos nginx" | ||
| systemctl restart nginx | ||
|
|
||
| echo "Instalamos Redis" | ||
| #echo "Instalamos Redis" | ||
| rpm -ivh $repo_redis_ib01/jemalloc-3.6.0-1.el7.x86_64.rpm | ||
| rpm -ivh $repo_redis_ib01/jemalloc-devel-3.6.0-1.el7.x86_64.rpm | ||
| rpm -ivh $repo_redis/redis-3.2.12-2.el7.x86_64.rpm | ||
|
|
||
| systemctl start redis | ||
| #systemctl start redis | ||
| systemctl enable redis | ||
|
|
||
| echo "Instalamos nodejs" | ||
| #echo "Instalamos nodejs" | ||
| rpm -ivh $repo_node/nodejs-14.15.1-1nodesource.x86_64.rpm | ||
|
|
||
| echo "Instalamos ImageMagick" | ||
| #echo "Instalamos ImageMagick" | ||
| yum -y install ImageMagick | ||
|
|
||
| echo "Instalamos libyaml" | ||
| #echo "Instalamos libyaml" | ||
| yum -y install libyaml | ||
|
|
||
| echo "Crear usuario deployer" | ||
| adduser deployer -G nginx | ||
| passwd deployer | ||
| #echo "Crear usuario deployer" | ||
| #adduser deployer -G nginx | ||
| #passwd deployer | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acá haría lo que hablamos, todo esto en un if si no existe. |
||
|
|
||
| echo "Copiamos archivos de sudoers" | ||
| cp $dir_conf/sudoers_deployer /etc/sudoers.d/deployer | ||
| #echo "Copiamos archivos de sudoers" | ||
| #cp $dir_conf/sudoers /etc/sudoers.d/deployer | ||
|
|
||
| echo "Creamos directorios" | ||
| mkdir -p /var/www/mawidabp.com/ | ||
| chown -R deployer: /var/www/ | ||
| #echo "Creamos directorios" | ||
| mkdir -p $mawidabp_path | ||
| chown -R $user: /var/www/ | ||
|
|
||
| echo "Exportamos RBENV" | ||
| #echo "Exportamos RBENV" | ||
| su deployer -c 'echo export PATH="$HOME/.rbenv/bin:$PATH" >> ~/.bashrc' | ||
| #su deployer -c 'echo eval "$(rbenv init -)"' | ||
|
|
||
| ##su deployer -c 'echo eval "$(rbenv init -)"' | ||
|
|
||
| echo "Copiamos servicios" | ||
| #echo "Copiamos servicios" | ||
| cp $dir_services/*.service /usr/lib/systemd/system/ | ||
|
|
||
| echo "Reemplazamos archivo de configuración selinux" | ||
| #echo "Reemplazamos archivo de configuración selinux" | ||
| /bin/cat $dir_services/selinux_config > /etc/selinux/config | ||
|
|
||
| echo "Finalizado por favor reinicie S.O." | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| $user ALL= NOPASSWD: /bin/systemctl start unicorn | ||
| $user ALL= NOPASSWD: /bin/systemctl stop unicorn | ||
| $user ALL= NOPASSWD: /bin/systemctl restart unicorn | ||
| $user ALL= NOPASSWD: /bin/systemctl reload unicorn | ||
| $user ALL= NOPASSWD: /bin/systemctl reload-or-restart unicorn | ||
|
|
||
| $user ALL= NOPASSWD: /bin/systemctl start sidekiq | ||
| $user ALL= NOPASSWD: /bin/systemctl stop sidekiq | ||
| $user ALL= NOPASSWD: /bin/systemctl restart sidekiq | ||
| $user ALL= NOPASSWD: /bin/systemctl reload sidekiq | ||
| $user ALL= NOPASSWD: /bin/systemctl reload-or-restart sidekiq |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| [Unit] | ||
| Description=unicorn | ||
| Requires= | ||
| Wants=postgresql-13.service | ||
| After=postgresql-13.service | ||
|
|
||
| [Service] | ||
| Type=forking | ||
| PermissionsStartOnly=true | ||
| User=$user | ||
| Group=nginx | ||
| WorkingDirectory=$mawidabp_path/current | ||
| Environment=RAILS_ENV=production | ||
| Environment=BUNDLE_GEMFILE=$mawidabp_path/current/Gemfile | ||
| SyslogIdentifier=unicorn | ||
| KillSignal=SIGQUIT | ||
| PIDFile=/tmp/unicorn.pid | ||
| ExecStartPre=/bin/mkdir -p /run/unicorn | ||
| ExecStartPre=/bin/chown -R $user:nginx /run/unicorn | ||
|
|
||
| ExecStart=/home/$user/.rbenv/shims/bundle exec "\ | ||
| $mawidabp_path/current/bin/unicorn -D -c \ | ||
| $mawidabp_path/current/config/unicorn.rb -E \ | ||
| production" | ||
|
|
||
| ExecStop=/bin/kill -s QUIT \$MAINPID | ||
| ExecReload=/bin/kill -s USR2 \$MAINPID | ||
|
|
||
| RestartSec=1 | ||
| Restart=on-failure | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
Uh oh!
There was an error while loading. Please reload this page.