From 933c07f6d6fbeed746dcc3b668fd3c75af199efa Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 24 Aug 2019 00:14:02 +0200 Subject: [PATCH] Add stuff to break remove failure and other app breaking the system --- break_yo_system_ynh/manifest.json | 42 +++++++++++++++++++++++++++++ break_yo_system_ynh/scripts/install | 20 ++++++++++++++ break_yo_system_ynh/scripts/remove | 16 +++++++++++ break_yo_system_ynh/scripts/upgrade | 16 +++++++++++ legacy_app_ynh/scripts/remove | 2 +- 5 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 break_yo_system_ynh/manifest.json create mode 100644 break_yo_system_ynh/scripts/install create mode 100644 break_yo_system_ynh/scripts/remove create mode 100644 break_yo_system_ynh/scripts/upgrade diff --git a/break_yo_system_ynh/manifest.json b/break_yo_system_ynh/manifest.json new file mode 100644 index 0000000..64f7157 --- /dev/null +++ b/break_yo_system_ynh/manifest.json @@ -0,0 +1,42 @@ +{ + "name": "Break your system!", + "id": "break_yo_system", + "description": { + "en": "That's a nice server you have here ... would be a shame if somebody was to ... break it !" + }, + "license": "WTFPL", + "maintainer": { + "name": "Aleks", + "email": "alex.aubin@mailoo.org", + "url": "https://github.com/alexAubin/" + }, + "requirements": { + "yunohost": ">> 3.6.0" + }, + "multi_instance": false, + "arguments": { + "install" : [ + { + "name": "domain", + "ask": { + "en": "Choose a domain" + }, + "example": "domain.org" + }, + { + "name": "breakwhat", + "ask": { + "en": "What script to break" + }, + "choices": { + "none" : "None", + "install" : "Install script", + "remove" : "Remove script", + "upgrade" : "Upgrade script", + "everything" : "Every script" + }, + "default": "none" + } + ] + } +} diff --git a/break_yo_system_ynh/scripts/install b/break_yo_system_ynh/scripts/install new file mode 100644 index 0000000..e3aa300 --- /dev/null +++ b/break_yo_system_ynh/scripts/install @@ -0,0 +1,20 @@ +set -eux + +source /usr/share/yunohost/helpers + +# Retrieve arguments +app=$YNH_APP_INSTANCE_NAME +domain=$YNH_APP_ARG_DOMAIN +breakwhat=$YNH_APP_ARG_BREAKWHAT + +ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app breakwhat $breakwhat + +if [[ $breakwhat == "install" ]] || [[ $breakwhat == "everything" ]] +then + echo "; WTF ; ?!() {{{{" > /etc/nginx/conf.d/$domain.d/$app.conf + service nginx restart || true # What could go wrong lol +else + touch /etc/nginx/conf.d/$domain.d/$app.conf + service nginx reload +fi diff --git a/break_yo_system_ynh/scripts/remove b/break_yo_system_ynh/scripts/remove new file mode 100644 index 0000000..0e61b7e --- /dev/null +++ b/break_yo_system_ynh/scripts/remove @@ -0,0 +1,16 @@ +set -eux + +source /usr/share/yunohost/helpers + +# Retrieve arguments +app=$YNH_APP_INSTANCE_NAME +domain=$(sudo yunohost app setting $app domain) +breakwhat=$(sudo yunohost app setting $app breakwhat) + +rm /etc/nginx/conf.d/$domain.d/$app.conf +service nginx reload + +if [[ $breakwhat == "remove" ]] || [[ $breakwhat == "everything" ]] +then + service nginx stop +fi diff --git a/break_yo_system_ynh/scripts/upgrade b/break_yo_system_ynh/scripts/upgrade new file mode 100644 index 0000000..a77da4d --- /dev/null +++ b/break_yo_system_ynh/scripts/upgrade @@ -0,0 +1,16 @@ +set -eux +source /usr/share/yunohost/helpers + +# Retrieve arguments +app=$YNH_APP_INSTANCE_NAME +domain=$(sudo yunohost app setting $app domain) +breakwhat=$(sudo yunohost app setting $app breakwhat) + +if [[ $breakwhat == "upgrade" ]] || [[ $breakwhat == "everything" ]] +then + echo "; WTF ; ?!() {{{{" > /etc/nginx/conf.d/$domain.d/$app.conf + service nginx restart || true # What could go wrong lol +else + rm /etc/nginx/conf.d/$domain.d/$app.conf + service nginx reload +fi diff --git a/legacy_app_ynh/scripts/remove b/legacy_app_ynh/scripts/remove index 75fd1c0..fd33d71 100644 --- a/legacy_app_ynh/scripts/remove +++ b/legacy_app_ynh/scripts/remove @@ -8,7 +8,7 @@ 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 rm /etc/nginx/conf.d/$domain.d/$app.conf sudo rm -f /etc/importantfile db_user=$app