From 1ac88879d70ae99e5ef96dda194cbdddeb90600d Mon Sep 17 00:00:00 2001 From: Romain Garbage Date: Sun, 26 Feb 2017 13:23:38 +0200 Subject: [PATCH 01/13] Set proper type to vars in manifest.json --- manifest.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manifest.json b/manifest.json index 0fb8556..966b507 100644 --- a/manifest.json +++ b/manifest.json @@ -16,6 +16,7 @@ "install" : [ { "name": "domain", + "type": "domain", "ask": { "en": "Choose a domain for your Shaarli", "fr": "Choisissez un domaine pour votre Shaarli" @@ -24,6 +25,7 @@ }, { "name": "path", + "type": "path", "ask": { "en": "Choose a path for your Shaarli", "fr": "Choisissez un chemin pour votre Shaarli" @@ -60,6 +62,7 @@ }, { "name": "admin", + "type": "user", "ask": { "en": "Admin user", "fr": "Administrateur" From c91c1b6fd9bc73023561398c1cef1b39cb5aa36d Mon Sep 17 00:00:00 2001 From: Romain Garbage Date: Sun, 26 Feb 2017 18:10:37 +0200 Subject: [PATCH 02/13] Cleaning up the conf dir --- conf/config.php | 13 ---------- conf/init_config.php | 17 ------------- conf/init_config_user.php | 52 --------------------------------------- conf/options.php | 23 ----------------- conf/user_list.py | 3 --- 5 files changed, 108 deletions(-) delete mode 100644 conf/config.php delete mode 100644 conf/init_config.php delete mode 100644 conf/init_config_user.php delete mode 100644 conf/options.php delete mode 100644 conf/user_list.py diff --git a/conf/config.php b/conf/config.php deleted file mode 100644 index d59c7c7..0000000 --- a/conf/config.php +++ /dev/null @@ -1,13 +0,0 @@ - \ No newline at end of file diff --git a/conf/init_config.php b/conf/init_config.php deleted file mode 100644 index ce0b784..0000000 --- a/conf/init_config.php +++ /dev/null @@ -1,17 +0,0 @@ - diff --git a/conf/init_config_user.php b/conf/init_config_user.php deleted file mode 100644 index f0fc7ac..0000000 --- a/conf/init_config_user.php +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/php - $userlogin) -{ - $userlevel = '2'; - if ($userlogin == $GLOBALS['ynh_admin']) - { - $userlevel = '4'; - } - - $currentLogin = array($userlogin); - $currentPassword = array($userlogin => ''); - $currentLevel = array($userlogin => $userlevel); - $currentEmail = array($userlogin => ''); - - if (array_key_exists('login', $GLOBALS)) - { - $GLOBALS['login'] = array_merge($GLOBALS['login'], $currentLogin); - $GLOBALS['password'] = array_merge($GLOBALS['password'], $currentPassword); - $GLOBALS['level'] = array_merge($GLOBALS['level'], $currentLevel); - $GLOBALS['email'] = array_merge($GLOBALS['email'], $currentEmail); - } - else - { - $GLOBALS['login'] = $currentLogin; - $GLOBALS['password'] = $currentPassword; - $GLOBALS['level'] = $currentLevel; - $GLOBALS['email'] = $currentEmail; - } -} - -$userconf = ''; - -$userconf_file = '/home/yunohost.app/shaarli/data/config_user.php'; -if (!file_put_contents($userconf_file, $userconf) || strcmp(file_get_contents($userconf_file),$userconf)!=0) -{ - fwrite(STDERR, "Error while writing " . $userconf_file); - exit(1); -} - -?> diff --git a/conf/options.php b/conf/options.php deleted file mode 100644 index 56b818e..0000000 --- a/conf/options.php +++ /dev/null @@ -1,23 +0,0 @@ - Date: Sun, 26 Feb 2017 18:11:40 +0200 Subject: [PATCH 03/13] Add support for multi instances and config at install --- conf/config.json.php | 60 +++++++++++++++++++++ conf/datastore.php | 1 + conf/gen_hash.php | 7 +++ conf/ipbans.php | 10 ++++ conf/lastupdatecheck.txt | 1 + conf/log.txt | 0 conf/updates.txt | 1 + manifest.json | 15 +++++- scripts/install | 112 +++++++++++++++++++++++++++++---------- 9 files changed, 176 insertions(+), 31 deletions(-) create mode 100644 conf/config.json.php create mode 100644 conf/datastore.php create mode 100644 conf/gen_hash.php create mode 100644 conf/ipbans.php create mode 100644 conf/lastupdatecheck.txt create mode 100644 conf/log.txt create mode 100644 conf/updates.txt diff --git a/conf/config.json.php b/conf/config.json.php new file mode 100644 index 0000000..69a0604 --- /dev/null +++ b/conf/config.json.php @@ -0,0 +1,60 @@ + diff --git a/conf/datastore.php b/conf/datastore.php new file mode 100644 index 0000000..fa93c7f --- /dev/null +++ b/conf/datastore.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/conf/gen_hash.php b/conf/gen_hash.php new file mode 100644 index 0000000..e69dae1 --- /dev/null +++ b/conf/gen_hash.php @@ -0,0 +1,7 @@ + + diff --git a/conf/ipbans.php b/conf/ipbans.php new file mode 100644 index 0000000..9dadae2 --- /dev/null +++ b/conf/ipbans.php @@ -0,0 +1,10 @@ + + array ( + ), + 'BANS' => + array ( + ), +); +?> \ No newline at end of file diff --git a/conf/lastupdatecheck.txt b/conf/lastupdatecheck.txt new file mode 100644 index 0000000..2c2927f --- /dev/null +++ b/conf/lastupdatecheck.txt @@ -0,0 +1 @@ +0.7.0 */ \ No newline at end of file diff --git a/conf/log.txt b/conf/log.txt new file mode 100644 index 0000000..e69de29 diff --git a/conf/updates.txt b/conf/updates.txt new file mode 100644 index 0000000..fdf0452 --- /dev/null +++ b/conf/updates.txt @@ -0,0 +1 @@ +updateMethodMergeDeprecatedConfigFile;updateMethodRenameDashTags;updateMethodConfigToJson;updateMethodEscapeUnescapedConfig;updateMethodDatastoreIds \ No newline at end of file diff --git a/manifest.json b/manifest.json index 966b507..2ef9d98 100644 --- a/manifest.json +++ b/manifest.json @@ -2,6 +2,9 @@ "name": "Shaarli", "id": "shaarli", "packaging_format": 1, + "requirements": { + "yunohost": ">> 2.3.15" + }, "description": { "en": "The personal, minimalist, super-fast, no-database delicious clone", "fr": "Clone de delicious, rapide, simple et sans base de données." @@ -11,7 +14,7 @@ }, "url": "https://github.com/shaarli/Shaarli", "version": "0.8.3", - "multi_instance": "false", + "multi_instance": "true", "arguments": { "install" : [ { @@ -34,7 +37,7 @@ "default": "/shaarli" }, { - "name": "public", + "name": "is_public", "ask": { "en": "Is it a public Shaarli site ?", "fr": "Est-ce un site Shaarli public ?" @@ -68,6 +71,14 @@ "fr": "Administrateur" }, "example": "test" + }, + { + "name": "password", + "type": "password", + "ask": { + "en": "Define password for Shaarli user", + "fr": "Définissez le mot de passe de l'utilisateur Shaarli" + } } ] } diff --git a/scripts/install b/scripts/install index 3253cb3..b88c321 100644 --- a/scripts/install +++ b/scripts/install @@ -1,12 +1,38 @@ #!/bin/bash +# causes the shell to exit if any subcommand or pipeline returns a non-zero status +set -e + +# This is a multi-instance app, meaning it can be installed several times independently +# The id of the app as stated in the manifest is available as $YNH_APP_ID +# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...) +# The app instance name is available as $YNH_APP_INSTANCE_NAME +# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample +# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 +# - ynhexample__{N} for the subsequent installations, with N=3,4, ... +# The app instance name is probably what you are interested the most, since this is +# guaranteed to be unique. This is a good unique identifier to define installation path, +# db names, ... +app=$YNH_APP_INSTANCE_NAME + # Retrieve arguments -domain=$1 -path=$2 -is_public=$3 -title=$4 -privatelinkbydefault=$5 -admin=$6 +domain=$YNH_APP_ARG_DOMAIN +path=$YNH_APP_ARG_PATH +admin=$YNH_APP_ARG_ADMIN +is_public=$YNH_APP_ARG_IS_PUBLIC +title=$YNH_APP_ARG_TITLE +privatelinkbydefault=$YNH_APP_ARG_PRIVATELINKBYDEFAULT +password=$YNH_APP_ARG_PASSWORD + +# +## Retrieve arguments +#domain=$1 +#path=$2 +#is_public=$3 +#title=$4 +#privatelinkbydefault=$5 +#admin=$6 +# # Load common variables and helpers source ./_common.sh @@ -17,10 +43,10 @@ if [[ ! $? -eq 0 ]]; then echo "Error : the chosen admin user does not exist" exit 1 fi -sudo yunohost app setting shaarli admin -v $admin +sudo yunohost app setting $app admin -v $admin # Check domain/path availability -sudo yunohost app checkurl $domain$path -a shaarli +sudo yunohost app checkurl $domain$path -a $app if [[ ! $? -eq 0 ]]; then exit 1 fi @@ -29,53 +55,81 @@ fi sudo apt-get install php5-cli -y -qq # Copy files to the right place -app_home_path=/home/yunohost.app/shaarli -final_path=/var/www/shaarli +app_home_path=/home/yunohost.app/$app +final_path=/var/www/$app sudo mkdir -p $final_path # Download and extract in /var/www extract_shaarli -sudo mkdir -p $app_home_path/data -sudo mkdir -p $app_home_path/cache -sudo mkdir -p $app_home_path/pagecache -sudo mkdir -p $app_home_path/tmp -sudo mkdir -p $app_home_path/conf -sudo chown -R www-data: $app_home_path +# +#sudo mkdir -p $app_home_path/data +#sudo mkdir -p $app_home_path/cache +#sudo mkdir -p $app_home_path/pagecache +#sudo mkdir -p $app_home_path/tmp +#sudo mkdir -p $app_home_path/conf +#sudo chown -R www-data: $app_home_path +# +# generate the salt salt=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') + +# generate the hash with the password +password_hash=$(php ../conf/gen_hash.php $password $admin $salt) + +# set the proper value for substitution if [ $privatelinkbydefault = "No" ]; then privatelinkbydefault_php=false else privatelinkbydefault_php=true fi -sudo sed -i "s@YNH_SALT@$salt@g" ../conf/init_config.php -sudo sed -i "s@YNH_TIMEZONE@$(cat /etc/timezone)@g" ../conf/init_config.php -sudo sed -i "s@YNH_TITLE@$title@g" ../conf/init_config.php -sudo sed -i "s@YNH_PRIVATE_LINK_BY_DEFAULT@$privatelinkbydefault_php@g" ../conf/init_config.php -sudo sed -i "s@YNH_ADMIN@$admin@g" ../conf/init_config.php +# Prepare the configuration file +sudo sed -i "s@YNH_SALT@$salt@g" ../conf/config.json.php +sudo sed -i "s@YNH_ADMIN@$admin@g" ../conf/config.json.php +sudo sed -i "s@YNH_HASH@$password_hash@g" ../conf/config.json.php +sudo sed -i "s@YNH_TIMEZONE@$(cat /etc/timezone)@g" ../conf/config.json.php +sudo sed -i "s@YNH_TITLE@$title@g" ../conf/config.json.php +sudo sed -i "s@YNH_PRIVATE_LINK_BY_DEFAULT@$privatelinkbydefault_php@g" ../conf/config.json.php -sudo cp ../conf/options.php $app_home_path/data/options.php -sudo cp ../conf/init_config.php $app_home_path/data/config.php -sudo php ../conf/init_config_user.php $(sudo yunohost user list --json | python ../conf/user_list.py) +# +#sudo sed -i "s@YNH_SALT@$salt@g" ../conf/init_config.php +#sudo sed -i "s@YNH_TIMEZONE@$(cat /etc/timezone)@g" ../conf/init_config.php +#sudo sed -i "s@YNH_TITLE@$title@g" ../conf/init_config.php +#sudo sed -i "s@YNH_PRIVATE_LINK_BY_DEFAULT@$privatelinkbydefault_php@g" ../conf/init_config.php +#sudo sed -i "s@YNH_ADMIN@$admin@g" ../conf/init_config.php +# +#sudo cp ../conf/options.php $app_home_path/data/options.php +#sudo cp ../conf/init_config.php $app_home_path/data/config.php +#sudo php ../conf/init_config_user.php $(sudo yunohost user list --json | python ../conf/user_list.py) +# + +# Populate the data directory of the shaarli instance +sudo cp ../conf/config.json.php $final_path/data +sudo cp ../conf/datastore.php $final_path/data +sudo cp ../conf/ipbans.php $final_path/data +sudo cp ../conf/lastupdatecheck.txt $final_path/data +sudo cp ../conf/log.txt $final_path/data +sudo cp ../conf/updates.txt $final_path/data sudo find $final_path -type f | xargs sudo chmod 644 sudo find $final_path -type d | xargs sudo chmod 755 #sudo chown -R root: $final_path -sudo find $app_home_path -type f | xargs sudo chmod 600 -sudo find $app_home_path -type d | xargs sudo chmod 700 -sudo chown -R www-data: $app_home_path +# +#sudo find $app_home_path -type f | xargs sudo chmod 600 +#sudo find $app_home_path -type d | xargs sudo chmod 700 +#sudo chown -R www-data: $app_home_path +# # Modify Nginx configuration file and copy it to Nginx conf directory sudo sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf sudo sed -i "s@YNH_ALIAS@$final_path@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/shaarli.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf # Reload Nginx and regenerate SSOwat conf if [ $is_public = "Yes" ]; then -sudo yunohost app setting shaarli unprotected_uris -v "/" +sudo yunohost app setting $app unprotected_uris -v "/" fi sudo service nginx reload sudo yunohost app ssowatconf From d72e85f619bfad7e695e8cb191f8957cb98c7660 Mon Sep 17 00:00:00 2001 From: Romain Garbage Date: Sun, 26 Feb 2017 18:54:53 +0200 Subject: [PATCH 04/13] Some clean-up in the install script --- scripts/install | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/scripts/install b/scripts/install index b88c321..eaa2750 100644 --- a/scripts/install +++ b/scripts/install @@ -24,16 +24,6 @@ title=$YNH_APP_ARG_TITLE privatelinkbydefault=$YNH_APP_ARG_PRIVATELINKBYDEFAULT password=$YNH_APP_ARG_PASSWORD -# -## Retrieve arguments -#domain=$1 -#path=$2 -#is_public=$3 -#title=$4 -#privatelinkbydefault=$5 -#admin=$6 -# - # Load common variables and helpers source ./_common.sh @@ -62,15 +52,6 @@ sudo mkdir -p $final_path # Download and extract in /var/www extract_shaarli -# -#sudo mkdir -p $app_home_path/data -#sudo mkdir -p $app_home_path/cache -#sudo mkdir -p $app_home_path/pagecache -#sudo mkdir -p $app_home_path/tmp -#sudo mkdir -p $app_home_path/conf -#sudo chown -R www-data: $app_home_path -# - # generate the salt salt=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') @@ -92,18 +73,6 @@ sudo sed -i "s@YNH_TIMEZONE@$(cat /etc/timezone)@g" ../conf/config.json.php sudo sed -i "s@YNH_TITLE@$title@g" ../conf/config.json.php sudo sed -i "s@YNH_PRIVATE_LINK_BY_DEFAULT@$privatelinkbydefault_php@g" ../conf/config.json.php -# -#sudo sed -i "s@YNH_SALT@$salt@g" ../conf/init_config.php -#sudo sed -i "s@YNH_TIMEZONE@$(cat /etc/timezone)@g" ../conf/init_config.php -#sudo sed -i "s@YNH_TITLE@$title@g" ../conf/init_config.php -#sudo sed -i "s@YNH_PRIVATE_LINK_BY_DEFAULT@$privatelinkbydefault_php@g" ../conf/init_config.php -#sudo sed -i "s@YNH_ADMIN@$admin@g" ../conf/init_config.php -# -#sudo cp ../conf/options.php $app_home_path/data/options.php -#sudo cp ../conf/init_config.php $app_home_path/data/config.php -#sudo php ../conf/init_config_user.php $(sudo yunohost user list --json | python ../conf/user_list.py) -# - # Populate the data directory of the shaarli instance sudo cp ../conf/config.json.php $final_path/data sudo cp ../conf/datastore.php $final_path/data @@ -116,12 +85,6 @@ sudo find $final_path -type f | xargs sudo chmod 644 sudo find $final_path -type d | xargs sudo chmod 755 #sudo chown -R root: $final_path -# -#sudo find $app_home_path -type f | xargs sudo chmod 600 -#sudo find $app_home_path -type d | xargs sudo chmod 700 -#sudo chown -R www-data: $app_home_path -# - # Modify Nginx configuration file and copy it to Nginx conf directory sudo sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf sudo sed -i "s@YNH_ALIAS@$final_path@g" ../conf/nginx.conf From 4902c1ebba943e0f9c38b37a53fb794bf877d057 Mon Sep 17 00:00:00 2001 From: Romain Garbage Date: Sun, 26 Feb 2017 19:10:35 +0200 Subject: [PATCH 05/13] Update remove script --- scripts/remove | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/remove b/scripts/remove index ebd64ce..27d3f62 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,21 @@ #!/bin/bash -domain=$(sudo yunohost app setting shaarli domain) +# This is a multi-instance app, meaning it can be installed several times independently +# The id of the app as stated in the manifest is available as $YNH_APP_ID +# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...) +# The app instance name is available as $YNH_APP_INSTANCE_NAME +# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample +# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 +# - ynhexample__{N} for the subsequent installations, with N=3,4, ... +# The app instance name is probably what you are interested the most, since this is +# guaranteed to be unique. This is a good unique identifier to define installation path, +# db names, ... +app=$YNH_APP_INSTANCE_NAME -sudo rm -rf /var/www/shaarli -sudo rm -f /etc/nginx/conf.d/$domain.d/shaarli.conf -sudo rm -rf /home/yunohost.app/shaarli/data \ No newline at end of file +domain=$(sudo yunohost app setting $app domain) +www_path=$(sudo yunohost app setting $app path | sed -e 's@^/@@' -e 's@/$@@') + +sudo rm -rf /var/www/$www_path +sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf + +sudo service nginx reload From 963009da6557952c8c87c51b4f7df9558797b6a4 Mon Sep 17 00:00:00 2001 From: Romain Garbage Date: Sun, 26 Feb 2017 19:47:24 +0200 Subject: [PATCH 06/13] Fix remove script for multiple instances --- scripts/remove | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/remove b/scripts/remove index 27d3f62..6cc1615 100644 --- a/scripts/remove +++ b/scripts/remove @@ -13,9 +13,8 @@ app=$YNH_APP_INSTANCE_NAME domain=$(sudo yunohost app setting $app domain) -www_path=$(sudo yunohost app setting $app path | sed -e 's@^/@@' -e 's@/$@@') -sudo rm -rf /var/www/$www_path +sudo rm -rf /var/www/$app sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf sudo service nginx reload From 3febaaa94f73aab21d4a6a93a4f8dc7ccc768f2e Mon Sep 17 00:00:00 2001 From: Romain Garbage Date: Sun, 26 Feb 2017 19:48:14 +0200 Subject: [PATCH 07/13] Reorder questions in manifest.json ; add license field --- manifest.json | 57 ++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/manifest.json b/manifest.json index 2ef9d98..9553077 100644 --- a/manifest.json +++ b/manifest.json @@ -13,6 +13,7 @@ "name": "Lapineige" }, "url": "https://github.com/shaarli/Shaarli", + "license": "free", "version": "0.8.3", "multi_instance": "true", "arguments": { @@ -26,16 +27,6 @@ }, "example": "domain.org" }, - { - "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for your Shaarli", - "fr": "Choisissez un chemin pour votre Shaarli" - }, - "example": "/shaarli", - "default": "/shaarli" - }, { "name": "is_public", "ask": { @@ -43,24 +34,6 @@ "fr": "Est-ce un site Shaarli public ?" }, "choices": ["Yes", "No"], - "default": "No" - }, - { - "name": "title", - "ask": { - "en": "Choose a title for Shaarli's page", - "fr": "Choissez un titre pour la page Shaarli" - }, - "example": "Shaarli", - "default": "Shaarli" - }, - { - "name": "privatelinkbydefault", - "ask": { - "en": "Are new links private by default ?", - "fr": "Les nouveaux liens sont-ils privés par défaut ?" - }, - "choices": ["Yes", "No"], "default": "Yes" }, { @@ -79,6 +52,34 @@ "en": "Define password for Shaarli user", "fr": "Définissez le mot de passe de l'utilisateur Shaarli" } + }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for your Shaarli", + "fr": "Choisissez un chemin pour votre Shaarli" + }, + "example": "/shaarli", + "default": "/shaarli" + }, + { + "name": "title", + "ask": { + "en": "Choose a title for Shaarli's page", + "fr": "Choissez un titre pour la page Shaarli" + }, + "example": "Shaarli", + "default": "Shaarli" + }, + { + "name": "privatelinkbydefault", + "ask": { + "en": "Are new links private by default ?", + "fr": "Les nouveaux liens sont-ils privés par défaut ?" + }, + "choices": ["Yes", "No"], + "default": "Yes" } ] } From 2a6f053cfb4a238a8a0d8d35447a503be289cedd Mon Sep 17 00:00:00 2001 From: Romain Garbage Date: Mon, 27 Feb 2017 17:52:17 +0200 Subject: [PATCH 08/13] Fix permissions settings in install script --- scripts/install | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index eaa2750..bd15dd9 100644 --- a/scripts/install +++ b/scripts/install @@ -81,9 +81,18 @@ sudo cp ../conf/lastupdatecheck.txt $final_path/data sudo cp ../conf/log.txt $final_path/data sudo cp ../conf/updates.txt $final_path/data +# set proper permissions sudo find $final_path -type f | xargs sudo chmod 644 sudo find $final_path -type d | xargs sudo chmod 755 -#sudo chown -R root: $final_path +sudo chown -R root: $final_path + +#set proper ownership of the files in /data +sudo chown www-data:www-data $final_path/data/config.json.php +sudo chown www-data:www-data $final_path/data/datastore.php +sudo chown www-data:www-data $final_path/data/ipbans.php +sudo chown www-data:www-data $final_path/data/lastupdatecheck.txt +sudo chown www-data:www-data $final_path/data/log.txt +sudo chown www-data:www-data $final_path/data/updates.txt # Modify Nginx configuration file and copy it to Nginx conf directory sudo sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf From 6ceb1b5f1bbfa34b57b13104de3c81642e401cfa Mon Sep 17 00:00:00 2001 From: Romain Garbage Date: Mon, 27 Feb 2017 18:06:29 +0200 Subject: [PATCH 09/13] Fix install script: don't chown to root --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index bd15dd9..09aefe9 100644 --- a/scripts/install +++ b/scripts/install @@ -84,7 +84,7 @@ sudo cp ../conf/updates.txt $final_path/data # set proper permissions sudo find $final_path -type f | xargs sudo chmod 644 sudo find $final_path -type d | xargs sudo chmod 755 -sudo chown -R root: $final_path +#sudo chown -R root: $final_path #set proper ownership of the files in /data sudo chown www-data:www-data $final_path/data/config.json.php From 0d78874af16a500d58831c1de5cd575e3f2b96a8 Mon Sep 17 00:00:00 2001 From: Romain Garbage Date: Sun, 5 Mar 2017 10:12:23 +0200 Subject: [PATCH 10/13] Add the possibility of a private instance and update the README --- README.md | 11 +++++++++-- manifest.json | 13 +++++++++++-- scripts/install | 18 ++++++++++++++++-- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c85c145..d0dd04b 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,17 @@ Help for dev/testing hightly appreciated :) * Backup/restore scripts * Adding / removing a link * Upgrade *not tested* + * Configure Shaarli during installation + +## Installation information + +When doing the installation you will be prompted if you want to have a public site, meaning that you don't have to be a user of this Yunohost instance to access the site. + +You will also be asked if you want to have a private instance, meaning that the authentication will be deactivated and the application will be only available to the owner designed during install. ## TODO - - * Configure Shaarli during installation + + * Integrate the ssowat authentication (currently the authentication is done by Shaarli) * Test more the package ## Changelog diff --git a/manifest.json b/manifest.json index 9553077..b5a328b 100644 --- a/manifest.json +++ b/manifest.json @@ -40,8 +40,8 @@ "name": "admin", "type": "user", "ask": { - "en": "Admin user", - "fr": "Administrateur" + "en": "Owner of the Shaarli instance", + "fr": "Proprietaire de l'instance Shaarli" }, "example": "test" }, @@ -80,6 +80,15 @@ }, "choices": ["Yes", "No"], "default": "Yes" + }, + { + "name": "privateinstance", + "ask": { + "en": "Is the instance private?", + "fr": "Cette instance est elle privée ?" + }, + "choices": ["Yes", "No"], + "default": "No" } ] } diff --git a/scripts/install b/scripts/install index 09aefe9..ee98524 100644 --- a/scripts/install +++ b/scripts/install @@ -23,15 +23,22 @@ is_public=$YNH_APP_ARG_IS_PUBLIC title=$YNH_APP_ARG_TITLE privatelinkbydefault=$YNH_APP_ARG_PRIVATELINKBYDEFAULT password=$YNH_APP_ARG_PASSWORD +privateinstance=$YNH_APP_ARG_PRIVATEINSTANCE # Load common variables and helpers source ./_common.sh +# Check that the options are compatible +if [ $is_public = "Yes" ]; then + if [ $privateinstance = "Yes" ] ; then + ynh_die "Incompatible options: the instance cannot be both public and private" 1 + fi +fi + # Check that admin user is an existing account sudo yunohost user list --json | grep -q "\"username\": \"$admin\"" if [[ ! $? -eq 0 ]]; then -echo "Error : the chosen admin user does not exist" -exit 1 +ynh_die "Error : the chosen user does not exist" 1 fi sudo yunohost app setting $app admin -v $admin @@ -72,6 +79,10 @@ sudo sed -i "s@YNH_HASH@$password_hash@g" ../conf/config.json.php sudo sed -i "s@YNH_TIMEZONE@$(cat /etc/timezone)@g" ../conf/config.json.php sudo sed -i "s@YNH_TITLE@$title@g" ../conf/config.json.php sudo sed -i "s@YNH_PRIVATE_LINK_BY_DEFAULT@$privatelinkbydefault_php@g" ../conf/config.json.php +# turn off authentication on the instance +if [ $privateinstance = "Yes" ] ; then + sudo sed -i "/open_shaarli/s/false/true/" ../conf/config.json.php +fi # Populate the data directory of the shaarli instance sudo cp ../conf/config.json.php $final_path/data @@ -102,6 +113,9 @@ sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf # Reload Nginx and regenerate SSOwat conf if [ $is_public = "Yes" ]; then sudo yunohost app setting $app unprotected_uris -v "/" +elif [ $privateinstance = "Yes" ] ; then +# Configure SSOWat to prevent access for other users +sudo yunohost app setting $app allowed_users -v "$admin" fi sudo service nginx reload sudo yunohost app ssowatconf From 15c92da9fcf00b279a93ad1adc366ec369b08ffd Mon Sep 17 00:00:00 2001 From: lapineige Date: Sun, 5 Mar 2017 09:54:10 +0100 Subject: [PATCH 11/13] Fix accent in "Proprietaire" --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index b5a328b..a8e5f10 100644 --- a/manifest.json +++ b/manifest.json @@ -41,7 +41,7 @@ "type": "user", "ask": { "en": "Owner of the Shaarli instance", - "fr": "Proprietaire de l'instance Shaarli" + "fr": "Propriétaire de l'instance Shaarli" }, "example": "test" }, From f3c0e2f5e4e11ef7c320bdea5df9308d4cad199c Mon Sep 17 00:00:00 2001 From: lapineige Date: Sun, 5 Mar 2017 10:56:13 +0100 Subject: [PATCH 12/13] Make the app private by default --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index a8e5f10..89fd6ae 100644 --- a/manifest.json +++ b/manifest.json @@ -34,7 +34,7 @@ "fr": "Est-ce un site Shaarli public ?" }, "choices": ["Yes", "No"], - "default": "Yes" + "default": "No" }, { "name": "admin", @@ -88,7 +88,7 @@ "fr": "Cette instance est elle privée ?" }, "choices": ["Yes", "No"], - "default": "No" + "default": "Yes" } ] } From 366a6c1ee09d89ca1a7d77afa1008e437d5d35aa Mon Sep 17 00:00:00 2001 From: lapineige Date: Sun, 5 Mar 2017 12:28:54 +0100 Subject: [PATCH 13/13] Reorder install questions Right now it is closer to other Yunohost's apps installation processes (with domain + path as first question) and all the configuration for public/private mode are grouped. --- manifest.json | 56 +++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/manifest.json b/manifest.json index 89fd6ae..f279a1c 100644 --- a/manifest.json +++ b/manifest.json @@ -27,6 +27,16 @@ }, "example": "domain.org" }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for your Shaarli", + "fr": "Choisissez un chemin pour votre Shaarli" + }, + "example": "/shaarli", + "default": "/shaarli" + }, { "name": "is_public", "ask": { @@ -36,6 +46,24 @@ "choices": ["Yes", "No"], "default": "No" }, + { + "name": "privatelinkbydefault", + "ask": { + "en": "Are new links private by default ?", + "fr": "Les nouveaux liens sont-ils privés par défaut ?" + }, + "choices": ["Yes", "No"], + "default": "Yes" + }, + { + "name": "privateinstance", + "ask": { + "en": "Is this instance private?", + "fr": "Cette instance est-elle privée ?" + }, + "choices": ["Yes", "No"], + "default": "Yes" + }, { "name": "admin", "type": "user", @@ -53,16 +81,6 @@ "fr": "Définissez le mot de passe de l'utilisateur Shaarli" } }, - { - "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for your Shaarli", - "fr": "Choisissez un chemin pour votre Shaarli" - }, - "example": "/shaarli", - "default": "/shaarli" - }, { "name": "title", "ask": { @@ -71,24 +89,6 @@ }, "example": "Shaarli", "default": "Shaarli" - }, - { - "name": "privatelinkbydefault", - "ask": { - "en": "Are new links private by default ?", - "fr": "Les nouveaux liens sont-ils privés par défaut ?" - }, - "choices": ["Yes", "No"], - "default": "Yes" - }, - { - "name": "privateinstance", - "ask": { - "en": "Is the instance private?", - "fr": "Cette instance est elle privée ?" - }, - "choices": ["Yes", "No"], - "default": "Yes" } ] }