diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index bc0c0f7..0000000 --- a/conf/app.src +++ /dev/null @@ -1,5 +0,0 @@ -SOURCE_URL=https://github.com/thelounge/thelounge/archive/v4.2.0.tar.gz -SOURCE_SUM=6119c0692f03678940848ec19a8095ba67f8fdba42bb12481205314eabc0672d -SOURCE_SUM_PRG=sha256sum -ARCH_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true diff --git a/conf/deb.src b/conf/deb.src index 6bf6142..171fdba 100644 --- a/conf/deb.src +++ b/conf/deb.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/thelounge/thelounge/releases/download/v4.3.0-pre.6/thelounge_4.3.0.pre.6_all.deb -SOURCE_SUM=0224f2bf7b3223358b92be8fa5a5a68fd93b1547f791ed20f9107c8e5933256a +SOURCE_URL=https://github.com/thelounge/thelounge/releases/download/v4.3.0/thelounge_4.3.0_all.deb +SOURCE_SUM=60eaa836b677990a1508c86ded79f7bde8efb365240e5a0c60567757f5ea70e5 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=deb SOURCE_IN_SUBDIR=true diff --git a/conf/systemd.service b/conf/systemd.service index 0f6c708..8c0e0cd 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,6 @@ Wants=network-online.target Type=simple User=__APP__ Group=__APP__ -Environment="THELOUNGE_HOME=/home/yunohost.app/__APP__/" ExecStart=/usr/bin/thelounge start Restart=on-failure RestartSec=5 diff --git a/scripts/_common.sh b/scripts/_common.sh index b3656bc..ba69dff 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # nodejs version -nodejs_version=14 +nodejs_version=16 #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index a340da1..1d8d2ef 100644 --- a/scripts/install +++ b/scripts/install @@ -73,10 +73,7 @@ ynh_exec_warn_less dpkg -i $tempdir/thelounge.deb # CREATE DEDICATED USER #================================================= -# pushd $final_path -# ynh_use_nodejs -# ynh_exec_as $app env "$ynh_node_load_PATH" thelounge add $admin -# popd +# ynh_exec_as $app thelounge add $admin #================================================= # NGINX CONFIGURATION @@ -86,36 +83,17 @@ ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config -# #================================================= -# # CREATE DATA DIRECTORY -# #================================================= -# ynh_script_progression --message="Creating a data directory..." +#================================================= +# SPECIFIC SETUP +#================================================= +# MODIFY A CONFIG FILE +#================================================= +ynh_script_progression --message="Modifying a config file..." -# datadir=/home/yunohost.app/$app -# ynh_app_setting_set --app=$app --key=datadir --value=$datadir +ynh_add_config --template="../conf/config.js" --destination="/etc/thelounge/config.js" -# mkdir -p $datadir - -# chmod 750 "$datadir" -# chmod -R o-rwx "$datadir" -# chown -R $app:www-data "$datadir" - -# #================================================= -# # SPECIFIC SETUP -# #================================================= -# # MODIFY A CONFIG FILE -# #================================================= -# ynh_script_progression --message="Modifying a config file..." - -# ynh_add_config --template="../conf/config.js" --destination="$datadir/config.js" - -# #================================================= -# # SETUP SYSTEMD -# #================================================= -# ynh_script_progression --message="Configuring a systemd service..." - -# ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -# ynh_add_systemd_config +chmod 400 "/etc/thelounge/config.js" +chown $app:$app "/etc/thelounge/config.js" #================================================= # INTEGRATE SERVICE IN YUNOHOST diff --git a/scripts/restore b/scripts/restore index 13eded8..6a2d159 100644 --- a/scripts/restore +++ b/scripts/restore @@ -29,15 +29,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -48,38 +39,6 @@ ynh_script_progression --message="Restoring the NGINX configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring $app main directory..." - -ynh_restore_file --origin_path="$final_path" - -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - -#================================================= -# RESTORE THE CONFIG -#================================================= -ynh_script_progression --message="Restoring the config path..." - -ynh_restore_file --origin_path="$datadir" --not_mandatory - -mkdir -p $datadir - -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" - #================================================= # SPECIFIC RESTORATION #================================================= @@ -90,8 +49,16 @@ ynh_script_progression --message="Reinstalling dependencies..." # Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -# Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +tempdir="$(mktemp -d)" +ynh_setup_source --dest_dir=$tempdir --source_id=deb +ynh_exec_warn_less dpkg -i $tempdir/thelounge.deb + +#================================================= +# RESTORE VARIOUS FILES +#================================================= +ynh_script_progression --message="Restoring various files..." + +ynh_restore_file --origin_path="/etc/$app/" #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index 3ed90c3..70e53a5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,14 +18,11 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -49,19 +46,6 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/var/www/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path -fi - -# If datadir doesn't exist, create it -if [ -z "$datadir" ]; then - datadir=/home/yunohost.app/$app - mkdir -p /home/yunohost.app/$app - ynh_app_setting_set --app=$app --key=datadir --value=$datadir -fi - # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all @@ -78,14 +62,6 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action=stop --log_path=systemd -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -94,15 +70,13 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." - ynh_secure_remove --file="$final_path" - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir=$final_path -fi + ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" -chown -R $app:www-data $datadir + tempdir="$(mktemp -d)" + ynh_setup_source --dest_dir=$tempdir --source_id=deb + ynh_exec_warn_less dpkg -i $tempdir/thelounge.deb + +fi #================================================= # NGINX CONFIGURATION @@ -112,39 +86,11 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." - -# Install Nodejs -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version - -# Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" - -#================================================= -# SPECIFIC UPGRADE -#================================================= -# UPGRADE THE LOUNGE -#================================================= - -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - pushd $final_path - ynh_use_nodejs - ynh_exec_warn_less NODE_ENV=production yarn install - yarn add webpack webpack-dev-server --dev - ynh_exec_warn_less NODE_ENV=production yarn build - popd -fi - #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Upgrading systemd configuration..." -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" ynh_add_systemd_config #=================================================