-
Notifications
You must be signed in to change notification settings - Fork 11
/
INSTALL
69 lines (56 loc) · 1.93 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
63
64
65
66
67
68
69
#!/bin/bash
path=${1:-cloud-media-scripts}
upgrade="0"
if [ $(git config --get remote.origin.url | grep "cloud-media-scripts" | grep -v "grep" | wc -l) != "0" ]; then
mypwd="$(pwd)"
upgrade="1"
else
if [[ $path == /* ]]; then
mypwd="${path}"
else
mypwd="$(pwd)/${path}"
fi
fi
mypwd="${mypwd%/}"
tmppwd="${mypwd}"
if [ "${upgrade}" == "1" ]; then
answer=""
read -e -p "Do you want to upgrade scripts? Your config will NOT be changed or overwritten [Y/n]" -i "y" answer
if [ "${answer,,}" == "y" ]; then
tmppwd="${mypwd}/tmp$(date +%s)"
else
exit 0
fi
fi
git clone "https://github.com/madslundt/cloud-media-scripts.git" "${tmppwd}"
if [ "${upgrade}" == "1" ]; then
cp -rf "${tmppwd}/scripts" "${mypwd}"
cp -rf "${tmppwd}/config.template" "${mypwd}"
cp -rf "${tmppwd}/cron" "${mypwd}"
cp -rf "${tmppwd}/setup.sh" "${mypwd}"
rm -rf "${tmppwd}"
else
mkdir -p "${mypwd}/logs"
fi
if [ ! -e "${mypwd}/config" ]; then
cp "${mypwd}/config.template" "${mypwd}/config"
sed -i "s|INSERT_ROOT_DIR|${mypwd}|g" "${mypwd}/config"
fi
sed -i "s|INSERT_CONFIG_FILE|${mypwd}/config|g" "${mypwd}/scripts/"*
sed -i "s|INSERT_CONFIG_FILE|${mypwd}/config|g" "${mypwd}/setup.sh"
sed -i "s|bash mount.remote|bash ${mypwd}/scripts/mount.remote|g" "${mypwd}/scripts/"*
sed -i "s|bash umount.remote|bash ${mypwd}/scripts/umount.remote|g" "${mypwd}/scripts/"*
sed -i "s|bash mountcheck|bash ${mypwd}/scripts/mountcheck|g" "${mypwd}/scripts/"*
sed -i "s|logs/|${mypwd}/logs/|g" "${mypwd}/cron"
sed -i "s|scripts/|${mypwd}/scripts/|g" "${mypwd}/cron"
chmod a+x "${mypwd}/scripts/"*
chmod a+x "${mypwd}/setup.sh"
echo ""
echo ""
if [ "${upgrade}" == "1" ]; then
echo "Cloud-media-scripts has been upgraded successfully!"
else
echo "Cloud-media-scripts has been installed successfully!"
echo "Edit config file [${mypwd}/config] and run setup.sh [bash ${mypwd}/setup.sh]"
fi
exit 0