From f6d00bb09665247d5decc59bbce24c0d15a2df68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 3 Feb 2019 00:19:57 +0100 Subject: [PATCH 01/13] Fix install --- scripts/install | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/install b/scripts/install index 79f71ad..ee654e3 100644 --- a/scripts/install +++ b/scripts/install @@ -30,8 +30,6 @@ is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME -script_dir=$PWD - #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -68,6 +66,7 @@ yunohost firewall allow --no-upnp TCP $port 2>&1 ynh_app_setting_set $app domain $domain ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app port $port +ynh_app_setting_set $app path $path_url #================================================= # INSTALL DEPENDENCIES @@ -85,11 +84,10 @@ echo yes | sudo cpan Carton ynh_psql_test_if_first_run db_name=$(ynh_sanitize_dbid "$app") db_user=$db_name -db_pwd=$(ynh_string_random) -ynh_app_setting_set $app db_pwd $db_pwd -ynh_app_setting_set "$app" db_name "$db_name" # Initialize database and store postgres password for upgrade ynh_psql_setup_db "$db_name" "$db_user" +ynh_app_setting_set "$app" db_name "$db_name" +db_pwd=$(ynh_app_setting_get $app psqlpwd) # Password created in ynh_psql_setup_db function #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -142,7 +140,9 @@ ynh_add_systemd_config # Install lstu's dependencies via carton #================================================= -carton install +pushd $final_path +carton install --deployment --without=sqlite --without=mysql +popd #================================================= # SETUP LOGROTATE @@ -165,8 +165,8 @@ yunohost service add $app --log "/var/log/$app.log" ynh_app_setting_set $app skipped_uris "/" if [ $is_public -eq 0 ]; then # If the app is private, only the shortened URLs are publics - if [ "$path" == "/" ]; then - path="" + if [ "$path_url" == "/" ]; then + path_url="" fi ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" else @@ -177,14 +177,14 @@ fi # Configure owner #================================================= -sudo chown -R $app:$app $final_path +sudo chown -R www-data $final_path #================================================= # Start lstu #================================================= systemctl enable lstu.service -systemctl start lstu.service +systemctl start lstu #================================================= # RELOAD NGINX From 65e766b9f0e167bb46d6c66685aeda0847732b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 3 Feb 2019 00:20:08 +0100 Subject: [PATCH 02/13] Fix remove --- scripts/remove | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/remove b/scripts/remove index 9f2f483..4784fa9 100644 --- a/scripts/remove +++ b/scripts/remove @@ -17,6 +17,8 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get $app final_path) port=$(ynh_app_setting_get $app port) domain=$(ynh_app_setting_get $app domain) +db_name=$(ynh_app_setting_get $app db_name) +db_user=$db_name #================================================= # STANDARD REMOVE @@ -80,3 +82,9 @@ fi # Remove metapackage and its dependencies ynh_remove_app_dependencies + +#================================================= +# REMOVE THE PostgreSQL DATABASE +#================================================= + +ynh_psql_remove_db $db_name $db_user \ No newline at end of file From c2499821f95dfd02b7a17257d84160d82b3fd1e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 3 Feb 2019 00:20:19 +0100 Subject: [PATCH 03/13] Fix upgrade --- scripts/upgrade | 130 ++++++++++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 54 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 375c231..61a0ed9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,10 +1,7 @@ #!/bin/bash -# vim:set noexpandtab: - -set -eu #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -12,6 +9,17 @@ set -eu source _common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # LOAD SETTINGS #================================================= @@ -19,11 +27,14 @@ source /usr/share/yunohost/helpers app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) -path=$(ynh_app_setting_get $app path) +path_url=$(ynh_app_setting_get $app path) is_public=$(ynh_app_setting_get $app is_public) port=$(ynh_app_setting_get $app port) final_path=$(ynh_app_setting_get $app final_path) secret=$(ynh_app_setting_get $app secret) +db_name=$(ynh_app_setting_get $app db_name) +db_user=$db_name +db_pwd=$(ynh_app_setting_get $app psqlpwd) #================================================= # FIX OLD THINGS @@ -42,25 +53,23 @@ then # Si final_path n'est pas renseigné dans la config yunohost, cas d'ancien final_path=/var/www/$app fi -CHECK_PATH # Checks and corrects the syntax of the path. +domain_regex=$(echo "$domain" | sed 's@-@.@g') +CHECK_VAR "$domain_regex" "domain_regex empty" -# Get source -SETUP_SOURCE +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + +ynh_install_app_dependencies build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql + +ynh_setup_source "$final_path" #================================================= # NGINX CONFIGURATION #================================================= -# Copy Nginx configuration file -sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf -# Modify Nginx configuration file -sudo sed -i "s@__PATH__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf -sudo sed -i "s@__PORT__@$port@g" /etc/nginx/conf.d/$domain.d/$app.conf - -if [ $is_public -eq 1 ]; -then - sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf -fi +# Create a dedicated nginx config +ynh_add_nginx_config #================================================= # SPECIFIC UPGRADE @@ -68,65 +77,78 @@ fi # SETUP LSTU #================================================= -## Copie et configuration du fichier de conf. -CHECK_MD5_CONFIG "lstu.conf" "$final_path/lstu.conf" # Créé un backup du fichier de config si il a été modifié. -sudo cp ../conf/lstu.conf.template "$final_path/lstu.conf" -sudo sed -i "s@__DOMAIN__@$domain@g" "$final_path/lstu.conf" -sudo sed -i "s@__PATH__@$path@g" "$final_path/lstu.conf" -sudo sed -i "s@__PORT__@$port@g" "$final_path/lstu.conf" -sudo sed -i "s@__SECRET__@$secret@g" "${final_path}/lstu.conf" -STORE_MD5_CONFIG "lstu.conf" "$final_path/lstu.conf" # Réenregistre la somme de contrôle du fichier de config +ynh_backup_if_checksum_is_different "$final_path/lstu.conf" +cp ../conf/lstu.conf.template "${final_path}/lstu.conf" +ynh_replace_string "__DOMAIN__" "$domain" "${final_path}/lstu.conf" +ynh_replace_string "__PATH__" "$path_url" "${final_path}/lstu.conf" +ynh_replace_string "__PORT__" "$port" "${final_path}/lstu.conf" +ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lstu.conf" +ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lstu.conf" +ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lstu.conf" -#================================================= -# SETUP SYSTEMD -#================================================= - -# Mise en place du script systemd -sudo systemctl stop $app -sudo cp ../conf/lstu.service /etc/systemd/system/$app.service -sudo chown root: /etc/systemd/system/$app.service -sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/systemd/system/$app.service -## -sudo systemctl daemon-reload -## Démarrage auto du service -sudo systemctl enable $app - -#================================================= -# UPDATE LSTU'S DEPENDENCIES WITH CARTON -#================================================= - -pushd $final_path # cd avec une stack pour revenir en arrière -echo yes | sudo carton install 2>&1 | sudo tee -a "/var/log/$app/setup_carton.log" -popd # Revient au dossier courant avant pushd +secret=$(ynh_string_random 24) +ynh_replace_string "__SECRET__" "$secret" "${final_path}/lstu.conf" +ynh_store_file_checksum "${final_path}/lstu.conf" #================================================= # SECURING FILES AND DIRECTORIES #================================================= -sudo chown -R www-data: $final_path +chown -R www-data $final_path + +#================================================= +# SETUP SYSTEMD +#================================================= + +# Create a dedicated systemd config +ynh_add_systemd_config + +#================================================= +# Install lstu's dependencies via carton +#================================================= + +pushd $final_path +carton install --deployment --without=sqlite --without=mysql +popd + +#================================================= +# SETUP LOGROTATE +#================================================= + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add $app --log "/var/log/$app.log" #================================================= # RESTART LSTU #================================================= -sudo systemctl start lstu.service +systemctl reload lstu #================================================= # SETUP SSOWAT #================================================= +# Make app public or private ynh_app_setting_set $app skipped_uris "/" if [ $is_public -eq 0 ]; then # If the app is private, only the shortened URLs are publics - if [ "$path" == "/" ]; then - path="" + if [ "$path_url" == "/" ]; then + path_url="" fi - ynh_app_setting_set $app protected_regex "$domain_regex$path/login$","$domain_regex$path/logout$","$domain_regex$path/api$","$domain_regex$path/extensions$","$domain_regex$path/stats$","$domain_regex$path/d/.*$","$domain_regex$path/a$","$domain_regex$path/$" + ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" +else + ynh_replace_string "#--PRIVATE--" "" "/etc/nginx/conf.d/$domain.d/$app.conf" fi #================================================= # RELOAD NGINX #================================================= -sudo systemctl reload nginx -sudo yunohost app ssowatconf +systemctl reload nginx +yunohost app ssowatconf From 44edb17832ec85c6ecd8746b2a351d0e092f30b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 3 Feb 2019 00:20:47 +0100 Subject: [PATCH 04/13] Update manifest and app.src --- conf/app.src | 5 ++--- manifest.json | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index e14e01a..fd64580 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,5 @@ -SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lstu/-/archive/4388fad97387b5db4a12e7ce64d8c233d55b0a37/lstu-4388fad97387b5db4a12e7ce64d8c233d55b0a37.tar.gz -SOURCE_SUM=5bd073fb1129c1a16e3201b93fb340802c85772fb6f509bb3ee71b35793d2d33 +SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lstu/-/archive/0.21-4/lstu-0.21-4.tar.gz +SOURCE_SUM=28edf507a13e02917e55bd269c980739eaf9bcaf6924d51c432f1b3ed9cd4259 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= diff --git a/manifest.json b/manifest.json index dd9b10c..b0ca202 100644 --- a/manifest.json +++ b/manifest.json @@ -2,6 +2,7 @@ "name": "Lstu", "id": "lstu", "packaging_format": 1, + "version": "0.21-4~ynh1", "requirements": { "yunohost": ">= 2.4" }, From ff0dc2a3f418b1d5b8261ad84ff9646c5057fc81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 3 Feb 2019 01:02:32 +0100 Subject: [PATCH 05/13] update service --- conf/systemd.service | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/systemd.service b/conf/systemd.service index 1a69e8c..7d7683d 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,6 +8,8 @@ After=network.target Type=forking User=www-data RemainAfterExit=yes +Restart=always +RestartSec=10 WorkingDirectory=__FINALPATH__ PIDFile=__FINALPATH__/script/hypnotoad.pid ExecStart=/usr/local/bin/carton exec hypnotoad script/lstu From c2ea27ba08e5e0d8c06b2b310ebb421bca74497b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 3 Feb 2019 01:03:02 +0100 Subject: [PATCH 06/13] use variable insteed of app name --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index ee654e3..832deac 100644 --- a/scripts/install +++ b/scripts/install @@ -183,8 +183,8 @@ sudo chown -R www-data $final_path # Start lstu #================================================= -systemctl enable lstu.service -systemctl start lstu +systemctl enable $app.service +systemctl start $app #================================================= # RELOAD NGINX From 327c55d58760d5e895313f39f772a5b4b1917788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 3 Feb 2019 01:03:26 +0100 Subject: [PATCH 07/13] update Upgrade script --- scripts/upgrade | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 61a0ed9..63c311c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -53,9 +53,6 @@ then # Si final_path n'est pas renseigné dans la config yunohost, cas d'ancien final_path=/var/www/$app fi -domain_regex=$(echo "$domain" | sed 's@-@.@g') -CHECK_VAR "$domain_regex" "domain_regex empty" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -128,7 +125,7 @@ yunohost service add $app --log "/var/log/$app.log" # RESTART LSTU #================================================= -systemctl reload lstu +systemctl reload $app #================================================= # SETUP SSOWAT @@ -141,7 +138,7 @@ then # If the app is private, only the shortened URLs are publics if [ "$path_url" == "/" ]; then path_url="" fi - ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" + ynh_app_setting_set $app protected_regex "$domain$path_url/login$","$domain$path_url/logout$","$domain$path_url/api$","$domain$path_url/extensions$","$domain$path_url/stats$","$domain$path_url/d/.*$","$domain$path_url/a$","$domain$path_url/$" else ynh_replace_string "#--PRIVATE--" "" "/etc/nginx/conf.d/$domain.d/$app.conf" fi From 078d3c18b7ddf76db5aee7ca814f90f356f337f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 3 Feb 2019 01:03:43 +0100 Subject: [PATCH 08/13] update backup --- scripts/backup | 72 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 17 deletions(-) diff --git a/scripts/backup b/scripts/backup index deaac93..ce2eff4 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,27 +1,65 @@ #!/bin/bash -# vim:set noexpandtab: -# Exit on command errors and treat unset variables as an error -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Source app helpers +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -# Get multi-instances specific variables +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= + app=$YNH_APP_INSTANCE_NAME -# Retrieve app settings -domain=$(ynh_app_setting_get "$app" domain) +final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get $app domain) +db_name=$(ynh_app_setting_get $app db_name) -# Copy the app files -final_path="/var/www/${app}" -ynh_backup "${final_path}" "sources" 1 +#================================================= +# STANDARD BACKUP STEPS +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= -# Copy the nginx conf files -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" +ynh_backup "$final_path" -# Copy the lstu conf file -ynh_backup "${final_path}/lstu.conf" "lstu.conf" -ynh_backup "/etc/systemd/system/lstu.service" "systemd_lstu.service" -ynh_backup "/etc/logrotate.d/${app}" "logrotate_lstu" -ynh_backup "/var/log/${app}/production.log" "production.log" +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# BACKUP THE POSTGRESQL DATABASE +#================================================= + +ynh_psql_dump_db "$db_name" > db.sql + +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= + +ynh_backup "/etc/logrotate.d/$app" + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup "/etc/systemd/system/$app.service" \ No newline at end of file From bec4c2407b4f6b4e398a2be8d000f9868e11ba25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 3 Feb 2019 01:04:06 +0100 Subject: [PATCH 09/13] fix small bug in remove script --- scripts/remove | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/scripts/remove b/scripts/remove index 4784fa9..94eb6b8 100644 --- a/scripts/remove +++ b/scripts/remove @@ -29,16 +29,6 @@ db_user=$db_name # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE SERVICE FROM ADMIN PANEL -#================================================= - -if yunohost service status | grep -q $app -then - echo "Remove $app service" - yunohost service remove $app -fi - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -57,7 +47,7 @@ ynh_remove_nginx_config # Delete Log #================================================= -ynh_secure_remove "/var/log/$app/" +ynh_secure_remove "/var/log/$app.log" #================================================= # REMOVE LOGROTATE CONFIGURATION From 790fb2a42e959fe62abc0dd3edf006a68d522bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 3 Feb 2019 01:04:22 +0100 Subject: [PATCH 10/13] update restore script --- scripts/restore | 146 +++++++++++++++++++++++++----------------------- 1 file changed, 75 insertions(+), 71 deletions(-) diff --git a/scripts/restore b/scripts/restore index fc7d554..02f5892 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,97 +1,101 @@ #!/bin/bash -# vim:set noexpandtab: -# This restore script is adapted to Yunohost >=2.4 -# Exit on command errors and treat unset variables as an error -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Source app helpers +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -# The parameter $app is the id of the app instance ex: ynhexample__2 +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + #### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= + app=$YNH_APP_INSTANCE_NAME -# Get old parameter of the app domain=$(ynh_app_setting_get $app domain) -path=$(ynh_app_setting_get $app path) -is_public=$(ynh_app_setting_get $app is_public) +path_url=$(ynh_app_setting_get $app path) +final_path=$(ynh_app_setting_get $app final_path) +db_name=$(ynh_app_setting_get $app db_name) -ynh_package_update -ynh_package_install build-essential libssl-dev libpq-dev -echo yes | sudo cpan Carton +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= -# Check domain/path availability -sudo yunohost app checkurl "${domain}${path}" -a "${app}" \ - || ynh_die "Path not available: ${domain}${path}" +ynh_webpath_available $domain $path_url \ + || ynh_die "Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die "There is already a directory: $final_path " -# Check $final_path -final_path="/var/www/${app}" -if [ -d "${final_path}" ]; then - ynh_die "There is already a directory: ${final_path}" -fi +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= -# Check configuration files nginx -nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf" -if [ -f "${nginx_conf}" ]; then - ynh_die "The NGINX configuration already exists at '${nginx_conf}'. You should safely delete it before restoring this app." -fi +ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" -# Check configuration files lstu -lstu_conf="${final_path}/${app}.conf" -if [ -f "${lstu_conf}" ]; then - ynh_die "The LSTU CONF configuration already exists at '${lstu_conf}'. You should safely delete it before restoring this app." -fi +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= -lstu_systemd="/etc/systemd/system/${app}.service" -if [ -f "${lstu_systemd}" ]; then - ynh_die "The LSTU SYSTEMD configuration already exists at '${lstu_systemd}'. You should safely delete it before restoring this app." -fi +ynh_restore_file "$final_path" -lstu_logrotate="/etc/logrotate.d/${app}" -if [ -f "${lstu_logrotate}" ]; then - ynh_die "The LSTU LOGROTATE configuration already exists at '${lstu_logrotate}'. You should safely delete it before restoring this app." -fi +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= -lstu_log="/var/log/${app}/production.log" -if [ -f "${lstu_log}" ]; then - ynh_die "The LSTU LOG configuration already exists at '${lstu_log}'. You should safely delete it before restoring this app." -fi +db_pwd=$(ynh_app_setting_get $app psqlpwd) +ynh_psql_setup_db $db_name $db_name $db_pwd +ynh_psql_connect_as $db_name $db_pwd $db_name < ./db.sql - # Restore sources & data -sudo cp -a ./sources "${final_path}" +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= -# Set permissions -sudo chown -R www-data: "${final_path}" +# Define and install dependencies +ynh_install_app_dependencies build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql -# Restore nginx configuration files -sudo cp -a ./nginx.conf "${nginx_conf}" +#================================================= +# RESTORE SYSTEMD +#================================================= -# Restore lstu configuration files -sudo cp -a ./lstu.conf "${lstu_conf}" +ynh_restore_file "/etc/systemd/system/$app.service" +systemctl enable $app.service +systemctl start $app -# Restore service -sudo cp -a ./systemd_lstu.service "${lstu_systemd}" +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= -sudo cp -a ./logrotate_lstu "${lstu_logrotate}" +yunohost service add $app --log "/var/log/$app.log" -# Create log production -sudo mkdir "/var/log/${app}/" -sudo cp -a ./production.log "${lstu_log}" -# Delete symbolic link and restore -sudo rm -fr "${final_path}/log/production.log" -sudo ln -s "/var/log/${app}/production.log" "${final_path}/log/production.log" +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= -# Reload lstu service -sudo systemctl daemon-reload -sudo systemctl start lstu.service -sudo systemctl enable lstu.service +ynh_restore_file "/etc/logrotate.d/$app" -# Set ssowat config -if [ $is_public -eq 0 ]; -then - ynh_app_setting_delete $app skipped_uris -fi +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= -# Reload services -sudo systemctl reload nginx -sudo yunohost app ssowatconf +systemctl reload nginx +yunohost app ssowatconf From 79e335d2765c6fb5cf07cfae471eeea962d43e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 3 Feb 2019 01:24:33 +0100 Subject: [PATCH 11/13] Update README --- README.md | 77 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 891f0c8..0e4b0ea 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,74 @@ +# Lstu app for YunoHost -![WTFPL](http://www.wtfpl.net/wp-content/uploads/2012/12/wtfpl-badge-1.png) +[![Integration level](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) +[![Install lstu with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lstu) -# lstu_ynh +> *This package allow you to install lstu quickly and simply on a YunoHost server. +If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* -Seems to work, but need some testing. +## Overview +Lstu means Let's Shorten That Url. + +**Shipped version:** 0.21-4 + +## Screenshots + +![](https://framacloud.org/fr/cultiver-son-jardin/images/lstu/lstu-web.jpg) + +## Demo + +* [Official demo](https://lstu.fr) + +## Configuration + +How to configure this app: a plain file with SSH. + +## Documentation + + * Official documentation: https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home + +## YunoHost specific features + +#### Multi-users support + +Are LDAP and HTTP auth supported? **Not yet** +Can the app be used by multiple users? **Yes** + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lstu%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/lstu/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lstu%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lstu/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/lstu%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/lstu/) + + +**More information on the documentation page:** +https://yunohost.org/packaging_apps + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/lstu_ynh/issues + * App website: https://framagit.org/fiat-tux/hat-softwares/lstu + * YunoHost website: https://yunohost.org/ + +--- + +Developers info +---------------- + +**Only if you want to use a testing branch for coding, instead of merging directly into master.** +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/lstu_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug +or +sudo yunohost app upgrade lstu -u https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug +``` ## Todo - [ ] Integrate with LDAP - [ ] Add a question for the admin features' password - [ ] Allow to choose the database (sqlite or PostgreSQL) - [ ] Allow to choose to use Minion -- [ ] Add CI stuff - -# Contributing - -To contribute see the package lutim_ynh as example. -Pour contribuer regardez le paquet lutim_ynh comme exemple. - -lutim_ynh : https://github.com/YunoHost-Apps/lutim_ynh -Site officiel de lstu: https://framagit.org/luc/lstu - +- [ ] Add CI stuff \ No newline at end of file From 6381f257dfc3ef319d2705724b58432d9b4a0656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 3 Feb 2019 01:27:54 +0100 Subject: [PATCH 12/13] Better image --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e4b0ea..0d4bbf7 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Lstu means Let's Shorten That Url. ## Screenshots -![](https://framacloud.org/fr/cultiver-son-jardin/images/lstu/lstu-web.jpg) +![](https://framalibre.org/sites/default/files/Screenshot_20161213_120016_1.png) ## Demo From 588baf6b5a0357dbb672c04bc1b31528893b2fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 3 Feb 2019 01:34:52 +0100 Subject: [PATCH 13/13] add theme to todo list --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d4bbf7..f915081 100644 --- a/README.md +++ b/README.md @@ -71,4 +71,5 @@ sudo yunohost app upgrade lstu -u https://github.com/YunoHost-Apps/lstu_ynh/tree - [ ] Add a question for the admin features' password - [ ] Allow to choose the database (sqlite or PostgreSQL) - [ ] Allow to choose to use Minion -- [ ] Add CI stuff \ No newline at end of file +- [ ] Add CI stuff +- [ ] Theme choice (default or milligram) \ No newline at end of file