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