Add stuff to break remove failure and other app breaking the system

This commit is contained in:
Alexandre Aubin 2019-08-24 00:14:02 +02:00
parent a694881d1a
commit 933c07f6d6
5 changed files with 95 additions and 1 deletions

View file

@ -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"
}
]
}
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -8,7 +8,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
sudo rm -rf /var/www/$app 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 sudo rm -f /etc/importantfile
db_user=$app db_user=$app