From 50f86c111c779f9e373c6249ce11703909d5b09d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:19:55 +0200 Subject: [PATCH] cleaning --- conf/nginx.conf | 8 +++--- conf/systemd.service | 5 ++-- doc/DESCRIPTION_fr.md | 1 + manifest.toml | 4 +-- scripts/change_url | 6 ++-- scripts/install | 64 +++++++++++++++++++++++++++---------------- scripts/restore | 2 +- scripts/upgrade | 60 +++++++++++++++++++++++++++------------- 8 files changed, 95 insertions(+), 55 deletions(-) create mode 100644 doc/DESCRIPTION_fr.md diff --git a/conf/nginx.conf b/conf/nginx.conf index 237b8e9..0e3b018 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,13 +1,13 @@ -location __PATH__ { - # Standard nginx configuration +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + + proxy_pass http://127.0.0.1:__PORT__/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_pass http://localhost:__PORT__/; - # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } diff --git a/conf/systemd.service b/conf/systemd.service index fad5d1a..eb55328 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,12 +1,13 @@ [Unit] -Description=Emojiwall for Owncast +Description=Emojiwall: on-screen emotes overlay After=network.target [Service] Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__ +WorkingDirectory=__INSTALL_DIR__/ +Environment="__YNH_NODE_LOAD_PATH__" ExecStart=__YNH_NODE__ index.js # Sandboxing options to harden security diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..54b813c --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +Emojiwall (également connu sous le nom de « superposition d'émoticônes à l'écran ») prend les émojis et les émoticônes personnalisées envoyés dans le chat des streamers Owncast et les affiche en bouillonnant sur l'écran ! diff --git a/manifest.toml b/manifest.toml index 8aaa931..2aaeb4a 100644 --- a/manifest.toml +++ b/manifest.toml @@ -3,6 +3,7 @@ packaging_format = 2 id = "owncast-emojiwall" name = "Emojiwall for Owncast" description.en = "Emojiwall (on-screen emotes overlay) for Owncast" +description.fr = "Emojiwall (superposition d'émoticônes à l'écran) pour Owncast" description.id = "Dinding emoji (tayangan emoji dalam layar) untuk Owncast" version = "1.1.2~ynh1" @@ -52,6 +53,3 @@ ram.runtime = "50M" main.url = "/" [resources.ports] - - [resources.apt] - packages = "" diff --git a/scripts/change_url b/scripts/change_url index 1a0640b..0844ea6 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -14,14 +14,14 @@ source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression -m "Stopping the systemd service..." -w 1 +ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action -a stop +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression -m "Updating NGINX web server configuration..." -w 1 +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_change_url_nginx_config diff --git a/scripts/install b/scripts/install index f26de1f..452ec1b 100755 --- a/scripts/install +++ b/scripts/install @@ -9,56 +9,74 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=10 + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + #================================================= # APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression -m "Setting up source files..." -w 1 +ynh_script_progression --message="Setting up source files..." --weight=1 -ynh_setup_source -d "$install_dir" +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$install_dir" chown -R $app:www-data "$install_dir" -if [ "$path" = "/" ]; then - conf_path="" - else - conf_path=$path -fi - -ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_use_nodejs -npm --prefix "$install_dir" install -ynh_add_config -t default.json -d "$install_dir/config/default.json" +# if [ "$path" = "/" ]; then +# conf_path="" +# else +# conf_path=$path +# fi #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression -m "Adding system configurations related to $app..." -w 1 +ynh_script_progression --message"Adding system configurations related to $app..." --weight=1 ynh_add_nginx_config ynh_add_systemd_config -#================================================= -# APP INITIAL CONFIGURATION -#================================================= -# CONFIGURATION FOR SUBPATH -#================================================= -ynh_script_progression -m "Configuring the app..." -w 1 +yunohost service add $app --description="Emojiwall for Owncast" --log="/var/log/$app/$app.log" -yunohost service add $app -d "Emojiwall for Owncast" -l "/var/log/$app/$app.log" +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +ynh_add_config --template="some_config_file" --destination="$install_dir/config/default.json" + +chmod 400 "$install_dir/config/default.json" +chown $app:$app "$install_dir/config/default.json" + +#================================================= +# CONFIGURE THE APP +#================================================= +ynh_script_progression --message="Configuring the app..." --weight=15 + +pushd $install_dir + ynh_use_nodejs + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install +popd #================================================= # GENERIC FINALIZATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression -m "Starting a systemd service..." -w 1 +ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action -a start +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression -m "Installation of $app completed" -l + +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/restore b/scripts/restore index a2cbff6..d55a75d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -39,7 +39,7 @@ yunohost service add $app --description="Web interface for Urban Dictionary" --l #================================================= ynh_script_progression --message="Reloading NGINX web server and $app's 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="systemd" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 610093b..04698c6 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,14 +11,22 @@ source /usr/share/yunohost/helpers upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=10 + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + #================================================= # STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression -m "Stopping a systemd service..." -w 1 +ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action -a stop +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) @@ -28,50 +36,64 @@ ynh_systemd_action -a stop if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression -m "Upgrading source files..." -w 1 + ynh_script_progression --message="Upgrading source files..." --weight=1 - ynh_setup_source -d "$install_dir" + ynh_setup_source -d "$install_dir" --keep="config/default.json" fi chown -R $app:www-data "$install_dir" -ynh_use_nodejs -npm --prefix "$install_dir" install - #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression -m "Upgrading system configurations related to $app..." -w 1 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +# Create a dedicated NGINX config ynh_add_nginx_config +# Create a dedicated systemd config +ynh_add_systemd_config + +yunohost service add $app --description="Emojiwall for Owncast" --log="/var/log/$app/$app.log" + #================================================= # RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) #================================================= # CONFIGURATION FOR SUBPATH #================================================= +# ynh_script_progression --message="Updating the configuration..." --weight=1 -ynh_script_progression -m "Updating the configuration..." -w 1 +# if [ "$path" = "/" ]; then +# conf_path="" +# else +# conf_path=$path +# fi -if [ "$path" = "/" ]; then - conf_path="" - else - conf_path=$path -fi +# ynh_add_config -t default.json -d "$install_dir/config/default.json" -ynh_add_config -t default.json -d "$install_dir/config/default.json" +#chmod 400 "$install_dir/config/default.json" +#chown $app:$app "$install_dir/config/default.json" -yunohost service add $app --description="Web frontend for Urban Dictionary" --log="/var/log/$app/$app.log" +#================================================= +# CONFIGURE THE APP +#================================================= +ynh_script_progression --message="Configuring the app..." --weight=15 + +pushd $install_dir + ynh_use_nodejs + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install +popd #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression -m "Starting the systemd service..." -w 1 +ynh_script_progression --message="Starting the systemd service..." --weight=1 -ynh_systemd_action -a start +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression -m "Upgrade of $app completed" -l +ynh_script_progression --message="Upgrade of $app completed" --last