aboutsummaryrefslogtreecommitdiff
path: root/scripts/remove
blob: d4e896fa25fe4fa6cdf12afcf72bacab63f5f55a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash

# Exit on command errors and treat unset variables as an error
set -u

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"
	sudo service mastodon-web.service stop
	sudo rm "/etc/systemd/system/mastodon-web.service"
	sudo systemctl disable mastodon-web.service
fi

# Stop mastodon-sidekiq
if [ -e "/etc/systemd/system/mastodon-sidekiq.service" ]; then
	echo "Delete systemd script"
	sudo service mastodon-sidekiq.service stop
	sudo rm "/etc/systemd/system/mastodon-sidekiq.service"
	sudo systemctl disable mastodon-sidekiq.service
fi

# Stop mastodon-sidekiq
if [ -e "/etc/systemd/system/mastodon-streaming.service" ]; then
	echo "Delete systemd script"
	sudo service mastodon-sidekiq.streaming stop
	sudo rm "/etc/systemd/system/mastodon-streaming.service"
	sudo systemctl disable mastodon-streaming.service
fi

# 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

# delete postgresql database & user
ynh_psql_drop_db $app
ynh_psql_drop_user $app

# Remove Debian package
#sudo apt-get remove --purge -y imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file curl git
# Delete redis package
#sudo apt-get remove --purge -y redis-server redis-tools
# Delete postgresql package
#sudo apt-get remove --purge -y postgresql postgresql-contrib
# Delete Ruby package
#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
SECURE_REMOVE '/opt/$app'
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"

REMOVE_NGINX_CONF	# Suppression de la configuration nginx

SECURE_REMOVE '/var/log/$app/'	# Suppression des log

# Remove user
sudo userdel -f $app

# Reload services
sudo service nginx reload

echo -e "\e[0m"	# Restore normal color