-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·129 lines (108 loc) · 3.65 KB
/
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# arklone cloud sync utility
# by ridgek
# Released under GNU GPLv3 license, see LICENSE.md.
source "/opt/arklone/src/config.sh"
echo "Now installing arklone cloud sync utility..."
############
# FILESYSTEM
############
# Create arklone user config dir
# eg,
# /home/user/.config/arklone
# This step is actually redundant since it's already handled by config.sh
# but should stay since it is required for install
if [[ ! -d "${ARKLONE[userCfgDir]}" ]]; then
mkdir "${ARKLONE[userCfgDir]}"
chown "${USER}":"${USER}" "${ARKLONE[userCfgDir]}"
fi
# Create backup dir from user setting in ${ARKLONE[userCfg]}
# Should be somewhere easily-accessible for non-Linux users,
# like a FAT partition or samba share
# ArkOS default is /roms/backup
# @todo ArkOS specific
if [[ ! -d "${ARKLONE[backupDir]}" ]]; then
mkdir "${ARKLONE[backupDir]}"
chown "${USER}":"${USER}" "${ARKLONE[backupDir]}"
# Create a lock file so we know not to delete on uninstall
else
touch "${ARKLONE[userCfgDir]}/.backupDir.lock"
fi
if [[ ! -d "${ARKLONE[backupDir]}/rclone" ]]; then
mkdir "${ARKLONE[backupDir]}/rclone"
chown "${USER}":"${USER}" "${ARKLONE[backupDir]}/rclone"
fi
########
# RCLONE
########
# Get the system architecture
SYS_ARCH=$(uname -m)
case $SYS_ARCH in
armv6*)
SYS_ARCH="arm"
;;
armv7*)
SYS_ARCH="arm-v7"
;;
aarch64 | arm64)
SYS_ARCH="arm64"
;;
i386 | i686)
SYS_ARCH="386"
;;
x86_64)
SYS_ARCH="amd64"
;;
esac
#Get the rclone download URL
RCLONE_PKG="rclone-current-linux-${SYS_ARCH}.deb"
RCLONE_URL="https://downloads.rclone.org/${RCLONE_PKG}"
# Check if user already has rclone installed
if rclone --version >/dev/null 2>&1; then
# Set a lock file so we can know to restore user's settings on uninstall
touch "${ARKLONE[userCfgDir]}/.rclone.lock"
fi
# Upgrade the user to the latest rclone
wget "${RCLONE_URL}" -O "${HOME}/${RCLONE_PKG}" \
&& sudo dpkg --force-overwrite -i "${HOME}/${RCLONE_PKG}"
rm "${HOME}/${RCLONE_PKG}"
# Make rclone config directory if it doesn't exit
if [[ ! -d "${HOME}/.config/rclone" ]]; then
mkdir "${HOME}/.config/rclone"
chown "${USER}":"${USER}" "${HOME}/.config/rclone"
fi
# Backup user's rclone.conf and move it to ${ARKLONE[backupDir]}/rclone/
# @todo ArkOS-specific
if [[ -f "${HOME}/.config/rclone/rclone.conf" ]]; then
echo "Backing up and moving your rclone.conf to EASYROMS"
cp "${HOME}/.config/rclone/rclone.conf" "${HOME}/.config/rclone/rclone.conf.arklone$(date +%s).bak"
# Suppress errors
mv "${HOME}/.config/rclone/rclone.conf" "${ARKLONE[backupDir]}/rclone/rclone.conf" 2>/dev/null
fi
# Create user-accessible rclone.conf in ${ARKLONE[backupDir]}
# and symlink it to the default rclone location
touch "${ARKLONE[backupDir]}/rclone/rclone.conf"
ln -v -s "${ARKLONE[backupDir]}/rclone/rclone.conf" "${HOME}/.config/rclone/rclone.conf"
chown "${USER}":"${USER}" "${HOME}/.config/rclone/rclone.conf"
chown "${USER}":"${USER}" "${ARKLONE[backupDir]}/rclone/rclone.conf"
###############
# INOTIFY-TOOLS
###############
# Check if user already has inotify-tools installed
if which inotifywait >/dev/null 2>&1; then
# Set a lock file so we can know to not remove on uninstall
touch "${ARKLONE[userCfgDir]}/.inotify-tools.lock"
else
# Install inotify-tools
sudo apt update && sudo apt install inotify-tools -y
fi
#########
# ARKLONE
#########
# Make scripts executable
SCRIPTS=($(find "${ARKLONE[installDir]}" -type f -name "*.sh"))
for script in ${SCRIPTS[@]}; do
sudo chmod a+x "${script}"
done
# Make systemd units directory writeable for user
sudo chown "${USER}":"${USER}" "${ARKLONE[installDir]}/src/systemd/units"