From 097c138c719be3eb6ae08ea3eb415717c24e3701 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 2 Feb 2019 03:03:50 +0100 Subject: [PATCH] adding pushd / popd --- conf/config.ini | 2 +- scripts/install | 14 ++++++++------ scripts/upgrade | 4 +++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/conf/config.ini b/conf/config.ini index cf164d0..feccda9 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -17,7 +17,7 @@ port = 3306 [app] site_name = __SITENAME__ site_description = __SITEDESCRIPTION__ -host = https://your-writefreely-url-instance.com +host = __DOMAIN_URL__ theme = write disable_js = false webfonts = true diff --git a/scripts/install b/scripts/install index e010efb..912cab0 100755 --- a/scripts/install +++ b/scripts/install @@ -76,7 +76,7 @@ app=$YNH_APP_INSTANCE_NAME ### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". ### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" -final_path=/var/www/$app +final_path="/var/www/$app" test ! -e "$final_path" || ynh_die "This path already contains a folder" # Normalize the url path syntax @@ -258,13 +258,13 @@ ynh_add_systemd_config ### (It's compatible with sed regular expressions syntax) # setup application config -sudo cp ../conf/config.ini $final_path/config.ini +sudo cp "../conf/config.ini" "$final_path/config.ini" ynh_replace_string "__DBNAME__" "$db_name" "$final_path/config.ini" ynh_replace_string "__DBUSER__" "$db_name" "$final_path/config.ini" ynh_replace_string "__DBPWD__" "$db_pwd" "$final_path/config.ini" ynh_replace_string "__PORT__" "$port" "$final_path/config.ini" -ynh_replace_string "https://your-writefreely-url-instance.com" "https://$domain$path_url" "$final_path/config.ini" +ynh_replace_string "__DOMAIN_URL__" "https://$domain$path_url" "$final_path/config.ini" ynh_replace_string "__SINGLEUSER__" "$single_user" "$final_path/config.ini" ynh_replace_string "__SITENAME__" "$site_name" "$final_path/config.ini" ynh_replace_string "__SITEDESCRIPTION__" "$site_description" "$final_path/config.ini" @@ -299,9 +299,11 @@ chown -R "$app":"$app" "/var/log/$app" # MAKE SETUP #================================================= -( cd $final_path && $final_path/writefreely --init-db ) -( cd $final_path && $final_path/writefreely --gen-keys ) -( cd $final_path && $final_path/writefreely --create-admin $admin:$password ) +pushd $final_path + sudo -u $app ./writefreely --init-db + sudo -u $app ./writefreely --gen-keys + sudo -u $app ./writefreely --create-admin "$admin":"$password" +popd #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 00d5bda..437464b 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -139,7 +139,9 @@ ynh_system_user_create "$app" "$final_path" # MAKE UPGRADE #================================================= -( cd $final_path && $final_path/writefreely --migrate ) +pushd $final_path + sudo -u $app ./writefreely --migrate +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.