From 7df5d04f0c084a4bacf3139bb8636f0685bac5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9?= Date: Wed, 13 Jan 2016 21:14:06 +0100 Subject: [PATCH 1/2] Fix 'secret' variable - see issue : https://github.com/abeudin/ffsync_ynh/issues/17 --- .gitignore | 5 +++++ scripts/install | 7 +++++-- scripts/upgrade | 11 +++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..58684de --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# From kateproject +.kateproject +.kateproject.d +.directory + diff --git a/scripts/install b/scripts/install index 3a61141..d1633d5 100644 --- a/scripts/install +++ b/scripts/install @@ -10,7 +10,7 @@ if [[ ! $? -eq 0 ]]; then exit 1 fi -# Generate random passworid +# Generate random password db_pwd=$(head -c 8 /dev/urandom | sha1sum | cut -d " " -f1) # Use 'FSyncMS' as database name and user @@ -20,6 +20,10 @@ db_user=ffsync sudo yunohost app initdb $db_user -p $db_pwd sudo yunohost app setting ffsync mysqlpwd -v $db_pwd +# Generate random password and save +secret=$(head -c 20 /dev/urandom | sha1sum | cut -d " " -f1) +sudo yunohost app setting $app secret -v $secret + # Check depends installation sudo apt-get install make python-dev python-virtualenv -y @@ -54,7 +58,6 @@ sudo chown ffsync:ffsync -R $final_path sudo chown ffsync /var/log/ffsync.log # Modify Nginx configuration file and copy it to Nginx conf directory -secret=$(head -c 20 /dev/urandom | sha1sum | cut -d " " -f1) sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/ffsync.conf diff --git a/scripts/upgrade b/scripts/upgrade index ade8b32..73a0ef2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -5,8 +5,16 @@ domain=$(sudo yunohost app setting ffsync domain) path=$(sudo yunohost app setting ffsync path) db_pwd=$(sudo yunohost app setting ffsync mysqlpwd) db_user=ffsync +final_path=/opt/yunohost/ffsync - +# Get secret variable +secret=$(sudo yunohost app setting ffsync secret) +# Get from conf file if not defined +if [[ -z $secret ]] +then + secret=$(sudo grep "secret =" $final_path/syncserver.ini | cut -d" " -f3) + sudo yunohost app setting $app secret -v $secret +fi # Check Swap if [ $(sudo swapon -s | wc -l) = 1 ]; @@ -26,7 +34,6 @@ then fi # Copy files to the right place -final_path=/opt/yunohost/ffsync sudo mkdir -p $final_path sudo cp -a ../sources/* $final_path sudo cp ../conf/ffsync /etc/init.d/ From ce1535df795eb752b52cc940f165c7434b1df646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9?= Date: Wed, 13 Jan 2016 21:20:58 +0100 Subject: [PATCH 2/2] Fix 'secret' variable - see issue : https://github.com/abeudin/ffsync_ynh/issues/17 --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index d1633d5..55cd2bd 100644 --- a/scripts/install +++ b/scripts/install @@ -22,7 +22,7 @@ sudo yunohost app setting ffsync mysqlpwd -v $db_pwd # Generate random password and save secret=$(head -c 20 /dev/urandom | sha1sum | cut -d " " -f1) -sudo yunohost app setting $app secret -v $secret +sudo yunohost app setting ffsync secret -v $secret # Check depends installation sudo apt-get install make python-dev python-virtualenv -y diff --git a/scripts/upgrade b/scripts/upgrade index 73a0ef2..396f0c9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -13,7 +13,7 @@ secret=$(sudo yunohost app setting ffsync secret) if [[ -z $secret ]] then secret=$(sudo grep "secret =" $final_path/syncserver.ini | cut -d" " -f3) - sudo yunohost app setting $app secret -v $secret + sudo yunohost app setting ffsync secret -v $secret fi # Check Swap