-
Notifications
You must be signed in to change notification settings - Fork 1
/
geninstaller
executable file
·74 lines (55 loc) · 1.78 KB
/
geninstaller
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
#!/bin/sh -e
# Variables for creating installer and uninstaller
version="$(./shaber -v)"
# shellcheck disable=SC2016
binlocation='$HOME/.local/bin'
# shellcheck disable=SC2016
fileslocation='$HOME/.local/share/shaber'
# shellcheck disable=SC2016
configlocation='$HOME/.local/share/shaber/default'
# Create temporary directory and add files
mkdir /tmp/shellsaber
cp ./config.default /tmp/shellsaber/config
cp ./shaber /tmp/shellsaber
# Create uninstaller
cat <<EOF > /tmp/shellsaber/shaber-uninstall
#!/bin/sh -e
printf "Uninstalling ShellSaber..\n"
[ "\$(ls -A "$fileslocation/enabled")" ] && {
printf "Error: You still have mods enabled, please disable or remove them before uninstalling ShellSaber!\n"
exit 1
}
printf "Removing shaber..."
rm -f "$binlocation/shaber"
printf " Done.\n"
printf "Removing mod files..."
rm -rf "$fileslocation"
printf " Done.\n"
printf "ShellSaber has been uninstalled!"
EOF
# Make uninstaller executable
chmod +x /tmp/shellsaber/shaber-uninstall
# Create installer
cat <<EOF > shaber-install
#!/bin/sh -e
printf "Welcome to the ShellSaber installer!
Version: $version
Extracting archive...\\r"
mkdir "/tmp/shellsaber"
sed -e '1,/^exit\$/d' "\$0" | tar xz -C "/tmp/shellsaber"
printf "Extracted archive.
Installing ShellSaber...\\r"
install -D -m 775 "/tmp/shellsaber/shaber" "$binlocation/shaber"
install -D -m 775 "/tmp/shellsaber/shaber-uninstall" "$binlocation/shaber-uninstall"
install -D -m 664 "/tmp/shellsaber/config" "$configlocation/config"
rm -rf "/tmp/shellsaber"
printf "Installed ShellSaber.
Installation complete!\\n"
exit
EOF
# Create and add archive containing scripts
tar cz -C "/tmp/shellsaber" shaber config shaber-uninstall >> shaber-install
# Remove temporary folder
rm -r "/tmp/shellsaber"
# Make installer executable
chmod +x shaber-install