-
Notifications
You must be signed in to change notification settings - Fork 4
/
install
executable file
·62 lines (48 loc) · 2.14 KB
/
install
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
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
#=================================================
# Here is a small hack to avoid multi install CI test to fail due
# to same ssh_user provided
if [[ "${PACKAGE_CHECK_EXEC:-}" = "1" ]] && [[ "$YNH_APP_INSTANCE_NUMBER" != "1" ]] ; then
ssh_user+="$YNH_APP_INSTANCE_NUMBER"
fi
ynh_system_user_exists --username=$ssh_user && ynh_die --message="This user already exists"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
install_borg_with_pip
#=================================================
# AUTORIZE SSH FOR THIS USER
#=================================================
ynh_script_progression --message="Configuring SSH public key for remote connexion..."
ynh_system_user_create --username=$ssh_user --home_dir=/home/$ssh_user --use_shell --groups ssh.app
home=/home/$ssh_user
mkdir -p $home/.ssh
chmod o=--- $home
chown -R $ssh_user:$ssh_user $home
touch $home/.ssh/authorized_keys
extra="--storage-quota $quota"
if [ "$quota" = "" ]; then
extra=""
fi
echo "command=\"borg serve $extra --restrict-to-repository $home/backup\",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc $public_key" >> $home/.ssh/authorized_keys
# Tweak to prevent the backup of the backup itself
touch $home/.nobackup
#=================================================
# SETUP CRON
#=================================================
ynh_script_progression --message="Configuring cron to monitor backup..."
ynh_add_config --template="monitor-backup" --destination="/etc/cron.d/$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last