aboutsummaryrefslogtreecommitdiff
path: root/scripts/remove
blob: 470455eda8f58e18538dc7f723803c2b194d16d2 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash

#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source _common.sh	# Loads the generic functions usually used in the script
# Source app helpers
source /usr/share/yunohost/helpers
source _future.sh



#=================================================
# LOAD SETTINGS
#=================================================

app=$YNH_APP_INSTANCE_NAME

# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
db_name=$(ynh_app_setting_get "$app" db_name)
if [ -z "$db_name" ]; then
	db_name="${app}_production"
	ynh_app_setting_set "$app" db_name "$db_name"
fi
db_user=$(ynh_sanitize_dbid "$app")
final_path=$(ynh_app_setting_get "$app" final_path)

#=================================================
# STANDARD REMOVE
#=================================================
# STOP AND REMOVE SERVICE
#=================================================

ynh_remove_systemd_config "$app-web"
ynh_remove_systemd_config "$app-sidekiq"
ynh_remove_systemd_config "$app-streaming"

#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#==============================================

if yunohost service status | grep -q "$app-web"
then
	echo "Remove $app-web service"
	yunohost service remove "$app-web"
fi

if yunohost service status | grep -q "$app-sidekiq"
then
	echo "Remove $app-sidekiq service"
	yunohost service remove "$app-sidekiq"
fi

if yunohost service status | grep -q "$app-streaming"
then
	echo "Remove $app-streaming service"
	yunohost service remove "$app-streaming"
fi

#=================================================
# REMOVE DEPENDENCIES
#=================================================

# Remove metapackage and its dependencies
ynh_remove_app_dependencies

#=================================================
# REMOVE THE PostgreSQL DATABASE
#=================================================

# delete postgresql database & user
ynh_psql_remove_db "$db_name" "$db_user"

#=================================================
# REMOVE APP MAIN DIR
#=================================================

# Remove the app directory securely
ynh_secure_remove "$final_path"

#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================

ynh_secure_remove "/etc/nginx/conf.d/${domain}.d/${app}.conf"
systemctl reload nginx

#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE THE CRON FILE
#=================================================

# Delete cronlog
ynh_secure_remove /etc/cron.d/$app

#=================================================
# REMOVE source.list
#=================================================
if [ "$(lsb_release --codename --short)" == "jessie" ]; then
	ynh_secure_remove /etc/apt/sources.list.d/backports.list
fi
ynh_secure_remove /etc/apt/sources.list.d/yarn.list

# Delete ruby exec
#ynh_secure_remove /usr/bin/ruby

#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================

userdel -f $app