mirror of
https://github.com/YunoHost-Apps/openproject_ynh.git
synced 2024-09-03 19:56:10 +02:00
Shell-check-ed
USing shellcheck to sanitize code.
This commit is contained in:
parent
0e34c2ea6a
commit
79a5eb325b
7 changed files with 111 additions and 121 deletions
|
@ -5,20 +5,20 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
pkg_dependencies="zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libgdbm-dev libncurses5-dev automake libtool bison libffi-dev git curl poppler-utils unrtf tesseract-ocr catdoc libxml2 libxml2-dev libxslt1-dev memcached rbenv postgresql postgresql-contrib libpq-dev apt-transport-https ca-certificates nginx"
|
export pkg_dependencies="zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libgdbm-dev libncurses5-dev automake libtool bison libffi-dev git curl poppler-utils unrtf tesseract-ocr catdoc libxml2 libxml2-dev libxslt1-dev memcached rbenv postgresql postgresql-contrib libpq-dev apt-transport-https ca-certificates nginx"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
exec_as() {
|
exec_as() {
|
||||||
echo "exec_as $@"
|
ynh_print_info "exec_as $*"
|
||||||
local USER=$1
|
local USER=$1
|
||||||
shift 1
|
shift 1
|
||||||
|
|
||||||
if [[ $USER = $(whoami) ]]; then
|
if [[ $USER = $(whoami) ]]; then
|
||||||
eval "$@"
|
eval "$@"
|
||||||
else
|
else
|
||||||
sudo -u "$USER" sh -c ". ~/.profile && $@"
|
sudo -u "$USER" sh -c ". ~/.profile && $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -24,9 +24,9 @@ ynh_script_progression --message="Loading installation settings..." --time --wei
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD BACKUP STEPS
|
# STANDARD BACKUP STEPS
|
||||||
|
@ -35,7 +35,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
|
@ -56,7 +56,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the PostgreSQL database..." --time --weight=1
|
ynh_script_progression --message="Backing up the PostgreSQL database..." --time --weight=1
|
||||||
|
|
||||||
sudo -u postgres pg_dump $db_name > db.postgres
|
ynh_psql_dump_db -d "$db_name" > db.postgres
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP FAIL2BAN CONFIGURATION
|
# BACKUP FAIL2BAN CONFIGURATION
|
||||||
|
@ -87,7 +87,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -27,7 +27,8 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||||
|
|
||||||
# Needed for helper "ynh_add_nginx_config"
|
# Needed for helper "ynh_add_nginx_config"
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
|
export final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
|
@ -60,8 +61,8 @@ then
|
||||||
# Make a backup of the original nginx config file if modified
|
# Make a backup of the original nginx config file if modified
|
||||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||||
# Set global variables for nginx helper
|
# Set global variables for nginx helper
|
||||||
domain="$old_domain"
|
export domain="$old_domain"
|
||||||
path_url="$new_path"
|
export path_url="$new_path"
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
fi
|
fi
|
||||||
|
@ -71,7 +72,7 @@ if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
# Delete file checksum for the old conf file location
|
# Delete file checksum for the old conf file location
|
||||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
mv "$nginx_conf_path" "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
# Store file checksum for the new config file location
|
# Store file checksum for the new config file location
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
|
117
scripts/install
117
scripts/install
|
@ -11,16 +11,22 @@ source /usr/share/yunohost/helpers
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# Dealing with script's variables
|
||||||
#=================================================
|
#=================================================
|
||||||
# TODO
|
# Note: variables are stored in a single location to avoid confusion
|
||||||
|
# and declaration sequencing issues.
|
||||||
|
# Arguments from Manifest
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url=$YNH_APP_ARG_PATH
|
path_url=$YNH_APP_ARG_PATH
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
language=$YNH_APP_ARG_LANGUAGE
|
language=$YNH_APP_ARG_LANGUAGE
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Build home dir in install file
|
# Installer variables
|
||||||
|
db_name=$(ynh_sanitize_dbid --db_name="$app")
|
||||||
|
db_pwd=$(ynh_string_random) # Generate a random password
|
||||||
|
db_user=$db_name
|
||||||
|
final_path="/var/www/$app"
|
||||||
_homedir="/var/$app/"
|
_homedir="/var/$app/"
|
||||||
|
|
||||||
# Find a free port.
|
# Find a free port.
|
||||||
|
@ -28,30 +34,34 @@ _homedir="/var/$app/"
|
||||||
# - By PUMA to fire app server listening to this port, and
|
# - By PUMA to fire app server listening to this port, and
|
||||||
# - Nginx to proxify on this.
|
# - Nginx to proxify on this.
|
||||||
port=$(ynh_find_port --port=6001)
|
port=$(ynh_find_port --port=6001)
|
||||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||||
|
|
||||||
final_path=/var/www/$app
|
|
||||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
|
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||||
|
|
||||||
#TODO
|
ynh_app_setting_set --app="$app" --key=db_name --value="$db_name"
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
ynh_app_setting_set --app="$app" --key=db_pwd --value="$db_pwd"
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
ynh_app_setting_set --app="$app" --key=domain --value="$domain"
|
||||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
|
||||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
ynh_app_setting_set --app="$app" --key=homedir --value="$_homedir"
|
||||||
ynh_app_setting_set --app=$app --key=homedir --value=$_homedir
|
ynh_app_setting_set --app="$app" --key=is_public --value="$is_public"
|
||||||
|
ynh_app_setting_set --app="$app" --key=language --value="$language"
|
||||||
|
ynh_app_setting_set --app="$app" --key=path --value="$path_url"
|
||||||
|
ynh_app_setting_set --app="$app" --key=port --value="$port"
|
||||||
|
|
||||||
|
# Make app public if necessary
|
||||||
|
[ "$is_public" -eq 1 ] && ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENVIRONMENT SETUP
|
# ENVIRONMENT SETUP
|
||||||
|
@ -62,14 +72,14 @@ ynh_app_setting_set --app=$app --key=homedir --value=$_homedir
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||||
ynh_system_user_create --username=$app --home_dir=$_homedir -s
|
ynh_system_user_create --username="$app" --home_dir="$_homedir" -s
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=1
|
ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -78,44 +88,43 @@ ynh_install_app_dependencies $pkg_dependencies
|
||||||
ynh_script_progression --message="Setting up Rbenv and Nodenv..." --weight=1
|
ynh_script_progression --message="Setting up Rbenv and Nodenv..." --weight=1
|
||||||
|
|
||||||
# 1: Ruby
|
# 1: Ruby
|
||||||
exec_as $app git clone -q https://github.com/rbenv/rbenv.git $_homedir/.rbenv
|
exec_as "$app" git clone -q https://github.com/rbenv/rbenv.git "$_homedir/.rbenv"
|
||||||
exec_as $app git clone -q https://github.com/rbenv/ruby-build.git $_homedir/.rbenv/plugins/ruby-build
|
exec_as "$app" git clone -q https://github.com/rbenv/ruby-build.git "$_homedir/.rbenv/plugins/ruby-build"
|
||||||
|
|
||||||
# 2: Node
|
# 2: Node
|
||||||
exec_as $app git clone -q https://github.com/nodenv/nodenv.git $_homedir/.nodenv
|
exec_as "$app" git clone -q https://github.com/nodenv/nodenv.git "$_homedir/.nodenv"
|
||||||
exec_as $app git clone -q git://github.com/nodenv/node-build.git $_homedir/.nodenv/plugins/node-build
|
exec_as "$app" git clone -q git://github.com/nodenv/node-build.git "$_homedir/.nodenv/plugins/node-build"
|
||||||
|
|
||||||
cat >> $_homedir/.profile << EOF
|
cat >> "$_homedir/.profile" << EOF
|
||||||
export PATH="$_homedir/.nodenv/bin:$_homedir/.rbenv/bin:$PATH"
|
export PATH="$_homedir/.nodenv/bin:$_homedir/.rbenv/bin:$PATH"
|
||||||
eval "\$(rbenv init -)"
|
eval "\$(rbenv init -)"
|
||||||
eval "\$(nodenv init -)"
|
eval "\$(nodenv init -)"
|
||||||
RAILS_ENV="production"
|
RAILS_ENV="production"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chown $app: $_homedir/.profile
|
chown "$app": "$_homedir/.profile"
|
||||||
|
|
||||||
ynh_script_progression --message="Setting up Ruby and Node..." --weight=1
|
ynh_script_progression --message="Setting up Ruby and Node..." --weight=1
|
||||||
|
|
||||||
# 3: Ruby setup
|
# 3: Ruby setup
|
||||||
exec_as $app rbenv install 2.6.4 > /dev/null
|
exec_as "$app" rbenv install 2.6.4 > /dev/null
|
||||||
exec_as $app rbenv rehash
|
exec_as "$app" rbenv rehash
|
||||||
exec_as $app rbenv global 2.6.4
|
exec_as "$app" rbenv global 2.6.4
|
||||||
|
|
||||||
# 3: Node setup
|
# 3: Node setup
|
||||||
exec_as $app nodenv install 12.11.0 > /dev/null
|
exec_as "$app" nodenv install 12.11.0 > /dev/null
|
||||||
exec_as $app nodenv rehash
|
exec_as "$app" nodenv rehash
|
||||||
exec_as $app nodenv global 12.11.0
|
exec_as "$app" nodenv global 12.11.0
|
||||||
|
|
||||||
# Test result
|
# Test result
|
||||||
exec_as $app ruby --version >/dev/null 2>&1 || ynh_die "Ruby installation failed with rubyenv"
|
exec_as "$app" ruby --version >/dev/null 2>&1 || ynh_die "Ruby installation failed with rubyenv"
|
||||||
exec_as $app node --version >/dev/null 2>&1 || ynh_die "Node installation failed with nodenv"
|
exec_as "$app" node --version >/dev/null 2>&1 || ynh_die "Node installation failed with nodenv"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path"
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
|
|
||||||
|
@ -129,12 +138,8 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# OPENPROJECT CONFIGURATION
|
# OPENPROJECT CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
|
||||||
db_pwd=$(ynh_string_random) # Generate a random password
|
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
||||||
db_user=$db_name
|
|
||||||
ynh_script_progression --message="Configuring OpenProject..." --weight=1
|
ynh_script_progression --message="Configuring OpenProject..." --weight=1
|
||||||
exec_as $app cat >> $final_path/config/database.yml << EOF
|
exec_as "$app" cat >> "$final_path/config/database.yml" << EOF
|
||||||
production:
|
production:
|
||||||
adapter: postgresql
|
adapter: postgresql
|
||||||
database: $db_name
|
database: $db_name
|
||||||
|
@ -147,7 +152,7 @@ EOF
|
||||||
ynh_store_file_checksum --file="$final_path/config/database.yml"
|
ynh_store_file_checksum --file="$final_path/config/database.yml"
|
||||||
|
|
||||||
#TODO Not sure aout this email sending. To be tested.
|
#TODO Not sure aout this email sending. To be tested.
|
||||||
exec_as $app cat >> $final_path/config/configuration.yml << EOF
|
exec_as "$app" cat >> "$final_path/config/configuration.yml" << EOF
|
||||||
production:
|
production:
|
||||||
# Outgoing emails configuration (see examples above)
|
# Outgoing emails configuration (see examples above)
|
||||||
email_delivery_method: :smtp
|
email_delivery_method: :smtp
|
||||||
|
@ -163,31 +168,29 @@ ynh_store_file_checksum --file="$final_path/config/configuration.yml"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1
|
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=dbpwd --value=$db_pwd # Store the password in the app's config
|
ynh_psql_create_user "$db_user" "$db_pwd"
|
||||||
|
ynh_psql_create_db "$db_name" "$db_user"
|
||||||
ynh_exec_as postgres psql -c "CREATE USER $app WITH PASSWORD '$db_pwd';"
|
|
||||||
ynh_exec_as postgres createdb -O $app $db_name
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RUBY POST-INSTALL
|
# RUBY POST-INSTALL
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Compiling OpenProject with NPM and RUBYGems..." --weight=1
|
ynh_script_progression --message="Compiling OpenProject with NPM and RUBYGems..." --weight=1
|
||||||
|
|
||||||
exec_as $app gem update --system
|
exec_as "$app" gem update --system
|
||||||
|
|
||||||
pushd $final_path
|
pushd "$final_path"
|
||||||
exec_as $app gem install puma
|
exec_as "$app" gem install puma
|
||||||
# TODO Remove if test success exec_as $app gem install bundler
|
exec_as "$app" bundle install --deployment --without development test therubyracer docker
|
||||||
exec_as $app bundle install --deployment --without development test therubyracer docker
|
exec_as "$app" npm install
|
||||||
exec_as $app npm install
|
|
||||||
|
|
||||||
ynh_script_progression --message="Provisioning assets..." --weight=1
|
ynh_script_progression --message="Provisioning assets..." --weight=1
|
||||||
|
|
||||||
exec_as $app ./bin/rake db:create
|
exec_as "$app" ./bin/rake db:create
|
||||||
exec_as $app ./bin/rake db:migrate
|
exec_as "$app" ./bin/rake db:migrate
|
||||||
exec_as $app ./bin/rake LOCALE=$language db:seed
|
exec_as "$app" ./bin/rake LOCALE="$language" db:seed
|
||||||
exec_as $app ./bin/rake assets:precompile
|
exec_as "$app" ./bin/rake assets:precompile
|
||||||
echo "export SECRET_KEY_BASE=$(./bin/rake secret)" >> /etc/environment
|
# shellcheck disable=SC2016
|
||||||
|
exec_as "$app" 'echo "export SECRET_KEY_BASE=$(./bin/rake secret)"' >> /etc/environment
|
||||||
. /etc/environment
|
. /etc/environment
|
||||||
|
|
||||||
chmod o+x .
|
chmod o+x .
|
||||||
|
@ -211,7 +214,7 @@ ynh_add_systemd_config
|
||||||
###
|
###
|
||||||
#### Set the app as temporarily public for curl call
|
#### Set the app as temporarily public for curl call
|
||||||
###ynh_script_progression --message="Configuring SSOwat..." --weight=1
|
###ynh_script_progression --message="Configuring SSOwat..." --weight=1
|
||||||
###ynh_app_setting_set --app=$app --key=skipped_uris --value="/"
|
###ynh_app_setting_set --app="$app" --key=skipped_uris --value="/"
|
||||||
#### Reload SSOwat config
|
#### Reload SSOwat config
|
||||||
###yunohost app ssowatconf
|
###yunohost app ssowatconf
|
||||||
###
|
###
|
||||||
|
@ -225,7 +228,7 @@ ynh_add_systemd_config
|
||||||
#### Remove the public access
|
#### Remove the public access
|
||||||
###if [ $is_public -eq 0 ]
|
###if [ $is_public -eq 0 ]
|
||||||
###then
|
###then
|
||||||
### ynh_app_setting_delete --app=$app --key=skipped_uris
|
### ynh_app_setting_delete --app="$app" --key=skipped_uris
|
||||||
###fi
|
###fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -236,11 +239,11 @@ ynh_script_progression --message="Configuring log rotation..." --weight=1
|
||||||
ynh_use_logrotate
|
ynh_use_logrotate
|
||||||
|
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
yunohost service add $app --log "/var/log/$app/$app.log"
|
yunohost service add "$app" --log "/var/log/$app/$app.log"
|
||||||
|
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
# SETUP FAIL2BAN
|
# SETUP FAIL2BAN
|
||||||
ynh_script_progression --message="Configuring fail2ban..." --weight=1
|
ynh_script_progression --message="Configuring fail2ban..." --weight=1
|
||||||
|
@ -253,12 +256,6 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failreg
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring SSOwat..." --weight=1
|
ynh_script_progression --message="Configuring SSOwat..." --weight=1
|
||||||
|
|
||||||
# Make app public if necessary
|
|
||||||
if [ $is_public -eq 1 ]
|
|
||||||
then
|
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
||||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
|
|
|
@ -16,11 +16,9 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
|
|
||||||
_homedir=/var/$app
|
_homedir=/var/$app
|
||||||
|
|
||||||
|
@ -31,10 +29,10 @@ _homedir=/var/$app
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Remove a service from the admin panel, added by `yunohost service add`
|
# Remove a service from the admin panel, added by `yunohost service add`
|
||||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
if ynh_exec_warn_less yunohost service status "$app" >/dev/null
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing $app service..." --weight=1
|
ynh_script_progression --message="Removing $app service..." --weight=1
|
||||||
yunohost service remove $app
|
yunohost service remove "$app"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -51,11 +49,8 @@ ynh_remove_systemd_config
|
||||||
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
|
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
[ -z $db_name ] || ynh_exec_as postgres dropdb $db_name
|
ynh_psql_drop_db "$db_name"
|
||||||
|
ynh_psql_drop_user "$db_user"
|
||||||
# If DBMS is empty, remove it.
|
|
||||||
_remaining_databases=$(sudo -iu postgres psql -l | grep "^(" | sed "s/^(\([^ ]*\) .*/\1/")
|
|
||||||
[ $_remaining_databases -lt 3 ] && apt remove postgresql postgresq-contribl
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
|
@ -106,7 +101,7 @@ ynh_remove_fail2ban_config
|
||||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete --username=$app
|
ynh_system_user_delete --username="$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
@ -18,20 +18,18 @@ ynh_script_progression --message="Loading settings..." --time --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
path_url=$(ynh_app_setting_get --app="$app" --key=path)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
db_user=$db_name
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
|
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
|
||||||
|
|
||||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
ynh_webpath_available --domain="$domain" --path_url="$path_url" \
|
||||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||||
test ! -d $final_path \
|
test ! -d "$final_path" \
|
||||||
|| ynh_die --message="There is already a directory: $final_path "
|
|| ynh_die --message="There is already a directory: $final_path "
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -55,14 +53,14 @@ ynh_restore_file --origin_path="$final_path"
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app
|
ynh_system_user_create --username="$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Restore permissions on app files
|
# Restore permissions on app files
|
||||||
chown -R $app: $final_path
|
chown -R "$app": "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE FAIL2BAN CONFIGURATION
|
# RESTORE FAIL2BAN CONFIGURATION
|
||||||
|
@ -81,35 +79,35 @@ ynh_systemd_action --action=restart --service_name=fail2ban
|
||||||
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
|
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
|
||||||
|
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE POSTGRESQL DATABASE
|
# RESTORE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --time --weight=1
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --time --weight=1
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=dbpwd)
|
exec_as postgres psql < db.postgres
|
||||||
sudo -u postgres psql < db.postgres
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1
|
ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||||
systemctl enable $app.service
|
systemctl enable "$app.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
yunohost service add $app --log "/var/log/$app/$app.log"
|
yunohost service add "$app" --log "/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
|
|
|
@ -16,13 +16,12 @@ ynh_script_progression --message="Loading installation settings..." --time --wei
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
path_url=$(ynh_app_setting_get --app="$app" --key=path)
|
||||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
is_public=$(ynh_app_setting_get --app="$app" --key=is_public)
|
||||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#language=$(ynh_app_setting_get --app="$app" --key=language)
|
||||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -43,23 +42,23 @@ ynh_script_progression --message="Ensuring downward compatibility..." --time --w
|
||||||
|
|
||||||
# Fix is_public as a boolean value
|
# Fix is_public as a boolean value
|
||||||
if [ "$is_public" = "Yes" ]; then
|
if [ "$is_public" = "Yes" ]; then
|
||||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
ynh_app_setting_set --app="$app" --key=is_public --value=1
|
||||||
is_public=1
|
is_public=1
|
||||||
elif [ "$is_public" = "No" ]; then
|
elif [ "$is_public" = "No" ]; then
|
||||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
ynh_app_setting_set --app="$app" --key=is_public --value=0
|
||||||
is_public=0
|
is_public=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If db_name doesn't exist, create it
|
# If db_name doesn't exist, create it
|
||||||
if [ -z "$db_name" ]; then
|
if [ -z "$db_name" ]; then
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
db_name=$(ynh_sanitize_dbid --db_name="$app")
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
ynh_app_setting_set --app="$app" --key=db_name --value="$db_name"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If final_path doesn't exist, create it
|
# If final_path doesn't exist, create it
|
||||||
if [ -z "$final_path" ]; then
|
if [ -z "$final_path" ]; then
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -86,7 +85,7 @@ ynh_abort_if_errors
|
||||||
# instead of /foo ....
|
# instead of /foo ....
|
||||||
# If nobody installed your app before 2.7, then you may
|
# If nobody installed your app before 2.7, then you may
|
||||||
# safely remove this line
|
# safely remove this line
|
||||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
path_url=$(ynh_normalize_url_path --path_url="$path_url")
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
|
@ -95,7 +94,7 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -122,7 +121,7 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
|
@ -130,7 +129,7 @@ ynh_install_app_dependencies $pkg_dependencies
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app
|
ynh_system_user_create --username="$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CONFIG FILE CHECKSUM
|
# STORE THE CONFIG FILE CHECKSUM
|
||||||
|
@ -173,7 +172,7 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failreg
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set permissions on app files
|
# Set permissions on app files
|
||||||
chown -R root: $final_path
|
chown -R root: "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
@ -184,7 +183,7 @@ ynh_script_progression --message="Upgrading SSOwat configuration..." --time --we
|
||||||
if [ $is_public -eq 1 ]
|
if [ $is_public -eq 1 ]
|
||||||
then
|
then
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway
|
# unprotected_uris allows SSO credentials to be passed anyway
|
||||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -192,7 +191,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
|
|
Loading…
Add table
Reference in a new issue