forked from MrTakedi/copilot-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestore
More file actions
executable file
·67 lines (48 loc) · 2.23 KB
/
restore
File metadata and controls
executable file
·67 lines (48 loc) · 2.23 KB
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
#!/bin/bash
source /usr/share/yunohost/helpers
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression "Restoring the app main directory..."
ynh_restore --origin_path="$install_dir"
chown -R "$app:www-data" "$install_dir"
chmod -R 750 "$install_dir"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression "Restoring the data directory..."
ynh_restore --origin_path="$data_dir" --not_mandatory
chown -R "$app:www-data" "$data_dir"
chmod -R 750 "$data_dir"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression "Reinstalling Bun runtime..."
# Install Bun using official installation script from bun.sh
# This is the recommended installation method per https://bun.sh/docs/installation
if ! command -v bun &> /dev/null; then
export BUN_INSTALL="$install_dir/.bun"
export HOME="$data_dir"
curl -fsSL https://bun.sh/install | bash
export PATH="$BUN_INSTALL/bin:$PATH"
fi
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore --origin_path="/etc/systemd/system/$app.service"
systemctl enable "$app.service" --quiet
ynh_restore --origin_path="/etc/logrotate.d/$app"
ynh_restore --origin_path="/var/log/$app/"
yunohost service add "$app" --description="Copilot API Proxy" --log="/var/log/$app/$app.log"
#=================================================
# RELOAD NGINX AND START APP
#=================================================
ynh_script_progression "Reloading NGINX web server and starting $app's systemd service..."
ynh_systemctl --service="$app" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Restoration completed for $app"