diff --git a/conf/nginx.conf b/conf/nginx.conf index 11e5ee0..59938b5 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -3,6 +3,11 @@ location YNH_WWW_PATH { # Path to source alias YNH_WWW_ALIAS ; + # rewrite all http request to https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + # Example PHP configuration index index.php; @@ -22,8 +27,9 @@ location YNH_WWW_PATH { fastcgi_index index.php; include fastcgi_params; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; } # Include SSOWAT user panel. diff --git a/manifest.json b/manifest.json index 19f2c7c..940568b 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,8 @@ "name": "YunoHost example app", "id": "ynhexample", "description": { - "en": "Example package for Yunohost applications." + "en": "Example package for Yunohost applications.", + "fr": "Exemple de package d'application pour Yunohost." }, "licence": "free", "maintainer": { @@ -16,14 +17,16 @@ { "name": "domain", "ask": { - "en": "Choose a domain for ynhexample" + "en": "Choose a domain for ynhexample", + "fr": "Choisissez un domaine pour ynhexample" }, "example": "example.com" }, { "name": "path", "ask": { - "en": "Choose a path for ynhexample" + "en": "Choose a path for ynhexample", + "fr": "Choisissez un chemin pour ynhexample" }, "example": "/example", "default": "/example" @@ -31,14 +34,16 @@ { "name": "admin", "ask": { - "en": "Choose an admin user" + "en": "Choose an admin user", + "fr": "Choisissez l'administrateur" }, "example": "johndoe" }, { "name": "is_public", "ask": { - "en": "Is it a public application ?" + "en": "Is it a public application ?", + "fr": "Est-ce une application publique ?" }, "choices": ["Yes", "No"], "default": "Yes" diff --git a/scripts/backup b/scripts/backup index e7fe7c7..f2bc33d 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,4 +1,8 @@ #!/bin/bash + +# causes the shell to exit if any subcommand or pipeline returns a non-zero status +set -e + app=ynhexample # The parameter $1 is the backup directory location @@ -9,6 +13,10 @@ sudo mkdir -p $backup_dir # Backup sources & data sudo cp -a /var/www/$app/. $backup_dir/sources +# Backup mysql database if needed +# db_pwd=$(sudo yunohost app setting $app mysqlpwd) +# sudo mysqldump -u $app -p$db_pwd $app > $backup_dir/$app.dmp + # Copy Nginx and YunoHost parameters to make the script "standalone" sudo cp -a /etc/yunohost/apps/$app/. $backup_dir/yunohost domain=$(sudo yunohost app setting $app domain) diff --git a/scripts/install b/scripts/install index f69cf7f..e207052 100755 --- a/scripts/install +++ b/scripts/install @@ -1,4 +1,8 @@ #!/bin/bash + +# causes the shell to exit if any subcommand or pipeline returns a non-zero status +set -e + app=ynhexample # Retrieve arguments @@ -12,15 +16,23 @@ sudo yunohost app setting $app admin -v "$admin" sudo yunohost app setting $app is_public -v "$is_public" # Check domain/path availability -sudo yunohost app checkurl $domain$path -a $app -if [[ ! $? -eq 0 ]]; then - exit 1 -fi +sudo yunohost app checkurl $domain$path -a $app \ + || (echo "Path not available: $domain$path" && exit 1) # Copy source files final_path=/var/www/$app sudo mkdir -p $final_path -sudo cp -a ../sources/* $final_path +sudo cp -a ../sources/. $final_path + +# Set permissions to app files +# you may need to make some file and/or directory writeable by www-data (nginx user) +sudo chown -R root:root $final_path + +# If your app use a MySQL database you can use these lines to bootstrap +# a database, an associated user and save the password in app settings +# db_pwd=$(openssl rand -hex 15) +# sudo yunohost app initdb $app -p $db_pwd +# sudo yunohost app setting $app mysqlpwd -v $db_pwd # Modify Nginx configuration file and copy it to Nginx conf directory sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf diff --git a/scripts/remove b/scripts/remove index e43b9f7..bb1556d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -13,6 +13,10 @@ sudo rm -rf /var/www/$app # Remove configuration files sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf +# If a database is used, remove it +# root_pwd=$(sudo cat /etc/yunohost/mysql) +# mysql -u root -p$root_pwd -e "DROP DATABASE $app ; DROP USER $app@localhost ;" + # If a dedicated php-fpm process is used : # #sudo rm -f /etc/php5/fpm/pool.d/$app.conf diff --git a/scripts/restore b/scripts/restore index df8f9bc..1c20f2e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,4 +1,8 @@ #!/bin/bash + +# causes the shell to exit if any subcommand or pipeline returns a non-zero status +set -e + app=ynhexample # The parameter $1 is the uncompressed restore directory location @@ -7,6 +11,14 @@ backup_dir=$1/apps/$app # Restore sources & data sudo cp -a $backup_dir/sources/. /var/www/$app +# Restore permissions to app files +# you may need to make some file and/or directory writeable by www-data (nginx user) +sudo chown -R root:root $final_path + +# Restore mysql database if needed +# db_pwd=$(sudo yunohost app setting $app mysqlpwd) +# sudo mysql -u $app -p$db_pwd $app < $backup_dir/$app.dmp + # Restore Nginx and YunoHost parameters sudo cp -a $backup_dir/yunohost/. /etc/yunohost/apps/$app domain=$(sudo yunohost app setting $app domain) diff --git a/scripts/upgrade b/scripts/upgrade index 96c9e7c..e490def 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,4 +1,8 @@ #!/bin/bash + +# causes the shell to exit if any subcommand or pipeline returns a non-zero status +set -e + app=ynhexample # Retrieve arguments @@ -13,7 +17,11 @@ path=${path%/} # Copy source files final_path=/var/www/$app sudo mkdir -p $final_path -sudo cp -a ../sources/* $final_path +sudo cp -a ../sources/. $final_path + +# Set permissions to app files +# you may need to make some file and/or directory writeable by www-data (nginx user) +sudo chown -R root:root $final_path # Modify Nginx configuration file and copy it to Nginx conf directory sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf