From ddce191fdb8656008fb1eabe2d5e36fad61bd4ef Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 11 Mar 2017 20:12:45 -0500 Subject: [PATCH] Initial commit --- change_url_app_ynh/conf/index.html | 5 ++++ change_url_app_ynh/conf/nginx.conf | 3 +++ change_url_app_ynh/manifest.json | 36 +++++++++++++++++++++++++++ change_url_app_ynh/scripts/change_url | 25 +++++++++++++++++++ change_url_app_ynh/scripts/install | 34 +++++++++++++++++++++++++ change_url_app_ynh/scripts/remove | 11 ++++++++ register_url_app_ynh/conf/index.html | 5 ++++ register_url_app_ynh/conf/nginx.conf | 3 +++ register_url_app_ynh/manifest.json | 36 +++++++++++++++++++++++++++ register_url_app_ynh/scripts/install | 34 +++++++++++++++++++++++++ register_url_app_ynh/scripts/remove | 11 ++++++++ 11 files changed, 203 insertions(+) create mode 100644 change_url_app_ynh/conf/index.html create mode 100644 change_url_app_ynh/conf/nginx.conf create mode 100644 change_url_app_ynh/manifest.json create mode 100644 change_url_app_ynh/scripts/change_url create mode 100644 change_url_app_ynh/scripts/install create mode 100644 change_url_app_ynh/scripts/remove create mode 100644 register_url_app_ynh/conf/index.html create mode 100644 register_url_app_ynh/conf/nginx.conf create mode 100644 register_url_app_ynh/manifest.json create mode 100644 register_url_app_ynh/scripts/install create mode 100644 register_url_app_ynh/scripts/remove diff --git a/change_url_app_ynh/conf/index.html b/change_url_app_ynh/conf/index.html new file mode 100644 index 0000000..47d0444 --- /dev/null +++ b/change_url_app_ynh/conf/index.html @@ -0,0 +1,5 @@ + + + This is a dummy app to test the change url feature. + + diff --git a/change_url_app_ynh/conf/nginx.conf b/change_url_app_ynh/conf/nginx.conf new file mode 100644 index 0000000..7242d79 --- /dev/null +++ b/change_url_app_ynh/conf/nginx.conf @@ -0,0 +1,3 @@ +location PATHTOCHANGE { + alias /var/www/FOLDER; +} diff --git a/change_url_app_ynh/manifest.json b/change_url_app_ynh/manifest.json new file mode 100644 index 0000000..8a175a3 --- /dev/null +++ b/change_url_app_ynh/manifest.json @@ -0,0 +1,36 @@ +{ + "name": "Change Url", + "id": "change_url_app", + "description": { + "en": "Dummy app to test change_url" + }, + "license": "GPL-3+", + "maintainer": { + "name": "bram", + "email": "cortex@worlddomination.be", + "url": "http://worlddomination.be" + }, + "requirements": { + "yunohost": ">> 2.4.0" + }, + "multi_instance": false, + "arguments": { + "install" : [ + { + "name": "domain", + "ask": { + "en": "Choose a domain" + }, + "example": "domain.org" + }, + { + "name": "path", + "ask": { + "en": "Choose a path" + }, + "example": "/", + "default": "/" + } + ] + } +} diff --git a/change_url_app_ynh/scripts/change_url b/change_url_app_ynh/scripts/change_url new file mode 100644 index 0000000..01a2b74 --- /dev/null +++ b/change_url_app_ynh/scripts/change_url @@ -0,0 +1,25 @@ +set -eux + +app=$YNH_APP_INSTANCE_NAME +number=$YNH_APP_INSTANCE_NUMBER + +# Retrieve arguments +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH +old_path_trimed=$YNH_APP_OLD_PATH_TRIMED + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH +new_path_trimed=$YNH_APP_NEW_PATH_TRIMED + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +if [[ "$new_path" == "" ]]; then + sudo sed -i "s@location .\+ {@location / {@g" $nginx_conf_path +else + sudo sed -i "s@location .\+ {@location $new_path_trimed {@g" $nginx_conf_path +fi + +if [ $old_domain != $new_domain ]; then + sudo mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf +fi diff --git a/change_url_app_ynh/scripts/install b/change_url_app_ynh/scripts/install new file mode 100644 index 0000000..396b80e --- /dev/null +++ b/change_url_app_ynh/scripts/install @@ -0,0 +1,34 @@ +set -eux + +app=$YNH_APP_INSTANCE_NAME +number=$YNH_APP_INSTANCE_NUMBER + +# Retrieve arguments +domain=$YNH_APP_ARG_DOMAIN +path=$YNH_APP_ARG_PATH + +# Check domain/path availability +sudo yunohost app checkurl $domain$path -a $app +if [[ ! $? -eq 0 ]]; then + exit 1 +fi + +if [[ "$path" == "" ]]; then + sed -i "s@PATHTOCHANGE@/@g" ../conf/nginx.conf +else + sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf +fi + +sudo sed -i "s@FOLDER@$app/@g" ../conf/nginx.conf + +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf + +sudo mkdir -p /var/www/$app + +sudo cp ../conf/index.html /var/www/$app + +# Reload Nginx and regenerate SSOwat conf +sudo service nginx reload + +sudo yunohost app setting $app unprotected_uris -v "/" +sudo yunohost app ssowatconf diff --git a/change_url_app_ynh/scripts/remove b/change_url_app_ynh/scripts/remove new file mode 100644 index 0000000..19f4c76 --- /dev/null +++ b/change_url_app_ynh/scripts/remove @@ -0,0 +1,11 @@ +set -eux + +# See comments in install script +app=$YNH_APP_INSTANCE_NAME + +domain=$(sudo yunohost app setting $app domain) + +sudo rm -rf /var/www/$app +sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf + +sudo service nginx reload diff --git a/register_url_app_ynh/conf/index.html b/register_url_app_ynh/conf/index.html new file mode 100644 index 0000000..b3e82e1 --- /dev/null +++ b/register_url_app_ynh/conf/index.html @@ -0,0 +1,5 @@ + + + This is a dummy app to test urlregister + + diff --git a/register_url_app_ynh/conf/nginx.conf b/register_url_app_ynh/conf/nginx.conf new file mode 100644 index 0000000..7242d79 --- /dev/null +++ b/register_url_app_ynh/conf/nginx.conf @@ -0,0 +1,3 @@ +location PATHTOCHANGE { + alias /var/www/FOLDER; +} diff --git a/register_url_app_ynh/manifest.json b/register_url_app_ynh/manifest.json new file mode 100644 index 0000000..dfbedae --- /dev/null +++ b/register_url_app_ynh/manifest.json @@ -0,0 +1,36 @@ +{ + "name": "RegisterUrl Test App", + "id": "register_url_app", + "description": { + "en": "App to test the yunohost app registerurl action" + }, + "license": "GPL-3+", + "maintainer": { + "name": "Aleks", + "email": "alex.aubin@mailoo.org", + "url": "https://github.com/alexAubin/" + }, + "requirements": { + "yunohost": ">> 2.4.0" + }, + "multi_instance": false, + "arguments": { + "install" : [ + { + "name": "domain", + "ask": { + "en": "Choose a domain" + }, + "example": "domain.org" + }, + { + "name": "path", + "ask": { + "en": "Choose a path" + }, + "example": "/", + "default": "/" + } + ] + } +} diff --git a/register_url_app_ynh/scripts/install b/register_url_app_ynh/scripts/install new file mode 100644 index 0000000..e01eae9 --- /dev/null +++ b/register_url_app_ynh/scripts/install @@ -0,0 +1,34 @@ +set -eux + +app=$YNH_APP_INSTANCE_NAME +number=$YNH_APP_INSTANCE_NUMBER + +# Retrieve arguments +domain=$YNH_APP_ARG_DOMAIN +path=$YNH_APP_ARG_PATH + +# Check domain/path availability +sudo yunohost app registerurl $app $domain $path +if [[ ! $? -eq 0 ]]; then + exit 1 +fi + +if [[ "$path" == "" ]]; then + sed -i "s@PATHTOCHANGE@/@g" ../conf/nginx.conf +else + sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf +fi + +sudo sed -i "s@FOLDER@$app/@g" ../conf/nginx.conf + +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf + +sudo mkdir -p /var/www/$app + +sudo cp ../conf/index.html /var/www/$app + +# Reload Nginx and regenerate SSOwat conf +sudo service nginx reload + +sudo yunohost app setting $app unprotected_uris -v "/" +sudo yunohost app ssowatconf diff --git a/register_url_app_ynh/scripts/remove b/register_url_app_ynh/scripts/remove new file mode 100644 index 0000000..19f4c76 --- /dev/null +++ b/register_url_app_ynh/scripts/remove @@ -0,0 +1,11 @@ +set -eux + +# See comments in install script +app=$YNH_APP_INSTANCE_NAME + +domain=$(sudo yunohost app setting $app domain) + +sudo rm -rf /var/www/$app +sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf + +sudo service nginx reload