-
Notifications
You must be signed in to change notification settings - Fork 4
/
quick_install.sh
executable file
·95 lines (72 loc) · 2.91 KB
/
quick_install.sh
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
#!/bin/bash
#=================================================
# CHECK IF YUNOHOST IS INSTALLED
#=================================================
if [ -e /usr/bin/yunohost ]
then
echo "YunoHost is installed on your server, you should have a look to the package Archivist_ynh. https://github.com/YunoHost-Apps/archivist_ynh"
echo -n "Would you really continue ? (y/N): "
read answer
# Set the answer at lowercase only
answer=${answer,,}
if [ "${answer:0:1}" != "y" ]
then
echo "Cancelled..."
exit 0
fi
fi
#=================================================
# CLONE ARCHIVIST
#=================================================
final_path=/opt/archivist
sudo mkdir -p "$final_path"
sudo git clone https://github.com/maniackcrudelis/archivist "$final_path"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
sudo apt-get install rsync encfs sshpass ccrypt lzop zstd lzip
#=================================================
# SETUP LOGROTATE
#=================================================
sudo mkdir -p /var/log/archivist
echo "/var/log/archivist/*.log {
# Rotate if the logfile exceeds 100Mo
size 100M
# Keep 12 old log maximum
rotate 12
# Compress the logs with gzip
compress
# Compress the log at the next cycle. So keep always 2 non compressed logs
delaycompress
# Copy and truncate the log to allow to continue write on it. Instead of move the log.
copytruncate
# Do not do an error if the log is missing
missingok
# Not rotate if the log is empty
notifempty
# Keep old logs in the same dir
noolddir
}" | sudo tee /etc/logrotate.d/archivist > /dev/null
#=================================================
# SET A DEFAULT CONFIGURATION
#=================================================
backup_dir="$final_path/backup"
enc_backup_dir="$final_path/encrypted_backup"
sudo mkdir -p "$backup_dir"
sudo cp "$final_path/Backup_list.conf.default" "$final_path/Backup_list.conf"
sudo sed -i "s@^backup_dir=.*@backup_dir=$backup_dir@" "$final_path/Backup_list.conf"
sudo sed -i "s@^enc_backup_dir=.*@enc_backup_dir=$enc_backup_dir@" "$final_path/Backup_list.conf"
sudo sed -i "s@^ynh_core_backup=.*@ynh_core_backup=false@" "$final_path/Backup_list.conf"
#=================================================
# SET THE CRON FILE
#=================================================
echo "0 2 * * * root nice -n10 $final_path/archivist.sh | tee -a /var/log/archivist/archivist.log 2>&1" \
| sudo tee /etc/cron.d/archivist > /dev/null
#=================================================
# SET A PASSKEY
#=================================================
sudo touch "$final_path/passkey"
sudo chmod 400 "$final_path/passkey"
sudo sed -i "s@^encrypt=.*@encrypt=true@" "$final_path/Backup_list.conf"
sudo sed -i "s@^cryptpass=.*@cryptpass=$final_path/passkey@" "$final_path/Backup_list.conf"
echo ">> Please add a key for encryption in the file $final_path/passkey"