diff --git a/scripts/backup b/scripts/backup index e5be661..ce9d365 100755 --- a/scripts/backup +++ b/scripts/backup @@ -29,7 +29,7 @@ app=$YNH_APP_INSTANCE_NAME 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) +db_name=$(ynh_app_setting_get $app db_name) #================================================= # STANDARD BACKUP STEPS @@ -52,11 +52,10 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #ynh_backup "/etc/php5/fpm/pool.d/$app.conf" #================================================= -# BACKUP THE PostgreSQL DATABASE +# BACKUP THE POSTGRESQL DATABASE #================================================= ynh_psql_dump_db "$db_name" > db.sql -#ynh_backup "db.sql" #================================================= # SPECIFIC BACKUP diff --git a/scripts/change_url b/scripts/change_url index 60e555b..3c520b8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_systemd_action source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/install b/scripts/install index f3a3092..edc5bbb 100755 --- a/scripts/install +++ b/scripts/install @@ -59,8 +59,6 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path ynh_webpath_register $app $domain $path_url @@ -105,7 +103,7 @@ ynh_app_setting_set $app port $port ### - As well as the section "REINSTALL DEPENDENCIES" in the restore script ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script -ynh_install_app_dependencies gettext postgresql postgresql-contrib libpq-dev git curl gcc make openssl libssl-dev pkg-config sqlite3 libsqlite3-dev +ynh_install_app_dependencies gettext postgresql postgresql-contrib libpq-dev git curl gcc make openssl libssl-dev pkg-config #================================================= # CREATE A POSTGRESQL DATABASE @@ -119,9 +117,9 @@ ynh_install_app_dependencies gettext postgresql postgresql-contrib libpq-dev git ### - As well as the section "RESTORE THE POSTGRESQL DATABASE" in the restore script ynh_psql_test_if_first_run -db_name="$app" +db_name=$(ynh_sanitize_dbid $app) db_pwd=$(ynh_string_random 30) -ynh_app_setting_set "$app" db_name "$db_name" +ynh_app_setting_set $app db_name $db_name ynh_app_setting_set "$app" db_pwd "$db_pwd" ynh_psql_create_user "$db_name" "$db_pwd" ynh_psql_execute_as_root \ @@ -141,14 +139,13 @@ ynh_app_setting_set $app final_path $final_path git clone https://github.com/Plume-org/Plume.git "$final_path/$app" # Create the media directory, where uploads will be stored -(cd $final_path && mkdir media ) +mkdir $final_path/media #================================================= # NGINX CONFIGURATION #================================================= ### `ynh_add_nginx_config` will use the file conf/nginx.conf - # Create a dedicated nginx config ynh_add_nginx_config @@ -189,6 +186,7 @@ chown -R "$app":"$app" "/var/log/$app" #================================================= # MODIFY A CONFIG FILE #================================================= + # setup application config sudo cp "../conf/.env" "$final_path/$app/.env" ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/$app/.env" @@ -209,7 +207,7 @@ pushd $final_path sudo -u "$app" RUSTUP_HOME=$final_path/.rustup CARGO_HOME=$final_path/.cargo bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=nightly' popd -export PATH="$PATH:$final_path/.cargo/bin:/usr/local/sbin" +export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" pushd $final_path/$app sudo -u "$app" env PATH=$PATH cargo install diesel_cli --no-default-features --features postgres --version '=1.3.0' diff --git a/scripts/remove b/scripts/remove index 538f71d..e3e1b6e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,7 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) port=$(ynh_app_setting_get $app port) -db_name=$(ynh_app_setting_get "$app" db_name) +db_name=$(ynh_app_setting_get $app db_name) final_path=$(ynh_app_setting_get $app final_path) #================================================= @@ -46,7 +46,7 @@ ynh_remove_systemd_config #================================================= # Remove a database if it exists, along with the associated user -ynh_psql_remove_db "$db_name" "$app" +ynh_psql_remove_db "$db_name" "$db_name" #================================================= @@ -56,7 +56,7 @@ ynh_psql_remove_db "$db_name" "$app" # Remove metapackage and its dependencies ynh_remove_app_dependencies -export PATH="$PATH:$final_path/.cargo/bin:/usr/local/sbin" +export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" pushd $final_path/$app sudo -u "$app" env PATH=$PATH cargo uninstall diesel_cli @@ -103,6 +103,7 @@ then echo "Close port $port" >&2 yunohost firewall disallow TCP $port 2>&1 fi + #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index 6e963e0..c5c84ae 100755 --- a/scripts/restore +++ b/scripts/restore @@ -95,7 +95,7 @@ chown -R "$app":"$app" $final_path #================================================= # Define and install dependencies -ynh_install_app_dependencies gettext postgresql postgresql-contrib libpq-dev git curl gcc make openssl libssl-dev pkg-config sqlite3 libsqlite3-dev +ynh_install_app_dependencies gettext postgresql postgresql-contrib libpq-dev git curl gcc make openssl libssl-dev pkg-config #================================================= @@ -107,12 +107,19 @@ systemctl enable $app.service systemctl daemon-reload #Fix Your search index is locked. -export PATH="$PATH:$final_path/.cargo/bin:/usr/local/sbin" +export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" pushd $final_path/$app sudo -u "$app" env PATH=$PATH plm search unlock popd +#================================================= +# CREATE LOG FOLDER +#================================================= + +mkdir -p "/var/log/$app" +chown -R "$app":"$app" "/var/log/$app" + #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= @@ -140,13 +147,6 @@ ynh_restore_file "/etc/logrotate.d/$app" #systemctl reload php5-fpm systemctl reload nginx -#================================================= -# CREATE LOG FOLDER -#================================================= - -mkdir -p "/var/log/$app" -chown -R "$app":"$app" "/var/log/$app" - #================================================= # START SERVICE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index bd42955..81f33db 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,7 +22,7 @@ admin=$(ynh_app_setting_get $app admin) is_public=$(ynh_app_setting_get $app is_public) final_path=$(ynh_app_setting_get $app final_path) -db_name=$(ynh_app_setting_get "$app" db_name) +db_name=$(ynh_app_setting_get $app db_name) admin_email=$(ynh_app_setting_get "$app" admin_email) secret_key=$(ynh_app_setting_get "$app" secret_key) name=$(ynh_app_setting_get "$app" name) @@ -113,7 +113,7 @@ ynh_add_nginx_config # UPGRADE DEPENDENCIES #================================================= -ynh_install_app_dependencies gettext postgresql postgresql-contrib libpq-dev git curl gcc make openssl libssl-dev pkg-config sqlite3 libsqlite3-dev +ynh_install_app_dependencies gettext postgresql postgresql-contrib libpq-dev git curl gcc make openssl libssl-dev pkg-config #================================================= # CREATE DEDICATED USER @@ -152,14 +152,21 @@ fi # DOWNLOAD, CHECK AND UNPACK PLUME SOURCE #================================================= -( cd $final_path && sudo -u "$app" RUSTUP_HOME=$final_path/.rustup CARGO_HOME=$final_path/.cargo bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=nightly' ) -PATH="$PATH:$final_path/.cargo/bin" - export PATH="$PATH:$final_path/.cargo/bin:/usr/local/sbin" - export FEATURES=postgres -chown -R "$app":"$app" "$final_path" -( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/cargo install --no-default-features --features postgres --force ) -( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/cargo install --no-default-features --features postgres --path plume-cli --force ) -( cd $final_path/$app && diesel migration run ) +# Set right permissions +chown -R "$app":"$app" $final_path + +# Install +pushd $final_path + sudo -u "$app" RUSTUP_HOME=$final_path/.rustup CARGO_HOME=$final_path/.cargo bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=nightly' +popd + +export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" + +pushd $final_path/$app + sudo -u "$app" env PATH=$PATH cargo install --no-default-features --features postgres --force + sudo -u "$app" env PATH=$PATH cargo install --no-default-features --features postgres --path plume-cli --force + sudo -u "$app" env PATH=$PATH diesel migration run +popd ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. @@ -177,6 +184,7 @@ ynh_use_logrotate --non-append #================================================= # SETUP SYSTEMD #================================================= + # Create a dedicated systemd config ynh_add_systemd_config