1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lufi_ynh.git synced 2024-09-03 19:36:28 +02:00

Fix upgrade from 0.01

This commit is contained in:
yalh76 2020-05-26 01:58:07 +02:00
parent d798663617
commit 6f471f7943
4 changed files with 35 additions and 16 deletions

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers

View file

@ -75,8 +75,13 @@ ynh_print_info --message="Configuring firewall..."
# Find an available port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
# Open this port
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
# Optional: Expose this port publicly
# (N.B. : you only need to do this if the app actually needs to expose the port publicly.
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
# Open the port
# ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
#=================================================
# INSTALL DEPENDENCIES
@ -84,6 +89,7 @@ ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
ynh_print_info --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies
# Install Carton
echo yes | cpanm Carton
@ -155,7 +161,7 @@ fi
ynh_store_file_checksum "$config"
#=================================================
# Install lufi's dependencies via carton
# INSTALL LUFI'S DEPENDENCIES VIA CARTON
#=================================================
ynh_print_info --message="Installing lufi..."
@ -166,6 +172,7 @@ popd
#=================================================
# SETUP CRON
#=================================================
ynh_print_info --message="Setuping a cron..."
cp ../conf/cron_lufi /etc/cron.d/$app
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file="/etc/cron.d/$app"
@ -202,7 +209,7 @@ ynh_use_logrotate
#=================================================
ynh_print_info --message="Integrating service in YunoHost..."
yunohost service add $app --log "$final_path/log/production.log"
yunohost service add $app --description "lufi service" --log "$final_path/log/production.log"
#=================================================
# START SYSTEMD SERVICE

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -48,6 +49,7 @@ test ! -d $final_path \
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_print_info --message="Restoring the nginx configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
@ -83,6 +85,7 @@ ynh_print_info --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
# Install Carton
echo yes | cpanm Carton
@ -109,7 +112,7 @@ systemctl enable $app.service
#=================================================
ynh_print_info --message="Integrating service in YunoHost..."
yunohost service add $app --log "$final_path/log/production.log"
yunohost service add $app --description "lufi service" --log "$final_path/log/production.log"
#=================================================
# START SYSTEMD SERVICE
@ -121,6 +124,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/
#=================================================
# RESTORE THE CRON FILE
#=================================================
ynh_print_info --message="Restoring the cron file..."
ynh_restore_file --origin_path="/etc/cron.d/$app"

View file

@ -51,6 +51,7 @@ fi
if [ "${#final_path}" -eq 0 ]
then # Si final_path n'est pas renseigné dans la config yunohost, cas d'ancien script, code final_path en dur
final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
if [ -z "$db_pwd" ]; then
@ -62,6 +63,7 @@ fi
if [ -z "$max_file_size" ]; then
max_file_size=100 # 100 Mo
ynh_app_setting_set --app=$app --key=max_file_size --value=$max_file_size
fi
#=================================================
@ -170,16 +172,9 @@ fi
ynh_store_file_checksum --file="$config"
#=================================================
# SETUP CRON
#=================================================
cp ../conf/cron_lufi /etc/cron.d/$app
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file="/etc/cron.d/$app"
chmod +x $final_path/script/lufi
#=================================================
# Install lufi's dependencies via carton
# INSTALL LUFI'S DEPENDENCIES VIA CARTON
#=================================================
ynh_print_info --message="Installing lufi..."
pushd $final_path
# Migrate from SQLite to PostgreSQL
@ -194,17 +189,29 @@ if [ $need_migration_from_sqlite_to_psql -eq 1 ]; then
chown -R $app: "$final_path/log/production.log"
fi
# Restart with news parameters
ynh_systemd_action -n $app -a restart -l "Creating process id file" -p "$final_path/log/production.log"
carton exec script/lufi sqliteToOtherDB
fi
carton install --deployment --without=sqlite --without=mysql --without=htpasswd --without=test
popd
#=================================================
# SETUP CRON
#=================================================
ynh_print_info --message="Setuping cron..."
cp ../conf/cron_lufi /etc/cron.d/$app
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file="/etc/cron.d/$app"
chmod +x $final_path/script/lufi
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add $app --log "$final_path/log/production.log"
yunohost service add $app --description "lufi service" --log "$final_path/log/production.log"
#=================================================
# SETUP LOGROTATE
@ -254,7 +261,7 @@ fi
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/production.log" --line_match="Creating process id file"
ynh_systemd_action --service_name=$app --action="restart" --log_path="$final_path/log/production.log" --line_match="Creating process id file"
#=================================================
# RELOAD NGINX