2017-04-08 04:04:27 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -u
|
|
|
|
|
2017-05-07 23:22:41 +02:00
|
|
|
if [ ! -e .fonctions ]; then
|
|
|
|
# Get file fonction if not been to the current directory
|
|
|
|
sudo cp ../settings/scripts/.fonctions ./.fonctions
|
|
|
|
sudo chmod a+rx .fonctions
|
|
|
|
fi
|
|
|
|
|
2017-04-08 04:04:27 +02:00
|
|
|
source .fonctions # Loads the generic functions usually used in the script
|
|
|
|
# Source app helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Get multi-instances specific variables
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
# Retrieve app settings
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
|
|
|
|
|
|
# Stop mastodon-web
|
|
|
|
if [ -e "/etc/systemd/system/mastodon-web.service" ]; then
|
|
|
|
echo "Delete systemd script"
|
2017-04-10 04:55:10 +02:00
|
|
|
sudo systemctl stop mastodon-web.service
|
2017-04-08 04:04:27 +02:00
|
|
|
sudo systemctl disable mastodon-web.service
|
2018-05-31 13:38:55 +02:00
|
|
|
ynh_secure_remove "/etc/systemd/system/mastodon-web.service"
|
2017-04-08 04:04:27 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Stop mastodon-sidekiq
|
|
|
|
if [ -e "/etc/systemd/system/mastodon-sidekiq.service" ]; then
|
|
|
|
echo "Delete systemd script"
|
2017-04-10 04:55:10 +02:00
|
|
|
sudo systemctl stop mastodon-sidekiq.service
|
2017-04-08 04:04:27 +02:00
|
|
|
sudo systemctl disable mastodon-sidekiq.service
|
2018-05-31 13:38:55 +02:00
|
|
|
ynh_secure_remove "/etc/systemd/system/mastodon-sidekiq.service"
|
2017-04-08 04:04:27 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Stop mastodon-sidekiq
|
|
|
|
if [ -e "/etc/systemd/system/mastodon-streaming.service" ]; then
|
|
|
|
echo "Delete systemd script"
|
2017-04-24 23:52:44 +02:00
|
|
|
sudo systemctl stop mastodon-streaming.service
|
2017-04-08 04:04:27 +02:00
|
|
|
sudo systemctl disable mastodon-streaming.service
|
2018-05-31 13:38:55 +02:00
|
|
|
ynh_secure_remove "/etc/systemd/system/mastodon-streaming.service"
|
2017-04-08 04:04:27 +02:00
|
|
|
fi
|
|
|
|
|
2017-04-10 04:55:10 +02:00
|
|
|
# Delete service on Yunohost monitoring
|
|
|
|
if sudo yunohost service status | grep -q mastodon-web
|
|
|
|
then
|
|
|
|
echo "Remove mastodon-web service"
|
|
|
|
sudo yunohost service remove mastodon-web
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Delete service on Yunohost monitoring
|
|
|
|
if sudo yunohost service status | grep -q mastodon-sidekiq
|
|
|
|
then
|
|
|
|
echo "Remove mastodon-sidekiq service"
|
|
|
|
sudo yunohost service remove mastodon-sidekiq
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Delete service on Yunohost monitoring
|
|
|
|
if sudo yunohost service status | grep -q mastodon-streaming
|
|
|
|
then
|
|
|
|
echo "Remove mastodon-streaming service"
|
|
|
|
sudo yunohost service remove mastodon-streaming
|
|
|
|
fi
|
|
|
|
|
2017-04-08 04:04:27 +02:00
|
|
|
# delete postgresql database & user
|
2017-04-10 04:55:10 +02:00
|
|
|
ynh_psql_drop_db "${app}_production"
|
2017-04-10 21:13:13 +02:00
|
|
|
ynh_psql_drop_role "${app}"
|
2017-04-08 04:04:27 +02:00
|
|
|
|
|
|
|
# Remove Debian package
|
2018-05-31 13:38:55 +02:00
|
|
|
#sudo apt-get remove --purge -y yarn
|
2017-04-08 04:04:27 +02:00
|
|
|
#sudo apt-get remove --purge -y imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file curl git
|
|
|
|
#sudo apt-get remove --purge -y redis-server redis-tools
|
|
|
|
#sudo apt-get remove --purge -y postgresql postgresql-contrib
|
|
|
|
#sudo apt-get remove --purge -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
|
|
|
|
|
|
|
|
# Delete app directory and configurations
|
2017-04-18 02:47:58 +02:00
|
|
|
ynh_secure_remove /opt/$app
|
2017-04-08 04:04:27 +02:00
|
|
|
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
|
|
|
|
2017-04-10 04:55:10 +02:00
|
|
|
# Delete nginx configuration
|
|
|
|
REMOVE_NGINX_CONF
|
2017-04-08 04:04:27 +02:00
|
|
|
|
2017-04-10 04:55:10 +02:00
|
|
|
# Delete cronlog
|
2017-04-18 02:47:58 +02:00
|
|
|
ynh_secure_remove /etc/cron.d/$app
|
2017-04-11 15:22:54 +02:00
|
|
|
# Delete source.list
|
2017-04-18 02:47:58 +02:00
|
|
|
ynh_secure_remove /etc/apt/sources.list.d/backports.list
|
2018-05-31 13:38:55 +02:00
|
|
|
#ynh_secure_remove /etc/apt/sources.list.d/yarn.list
|
2017-04-11 15:22:54 +02:00
|
|
|
|
|
|
|
# Delete ruby exec
|
2018-05-31 13:38:55 +02:00
|
|
|
#ynh_secure_remove /usr/bin/ruby
|
2017-04-11 15:22:54 +02:00
|
|
|
|
2017-04-08 04:04:27 +02:00
|
|
|
# Remove user
|
|
|
|
sudo userdel -f $app
|
|
|
|
|
|
|
|
# Reload services
|
2017-04-18 02:47:58 +02:00
|
|
|
sudo systemctl reload nginx
|
2017-04-08 04:04:27 +02:00
|
|
|
|
2017-04-10 15:40:28 +02:00
|
|
|
echo -e "\e[0m" # Restore normal color
|