-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·92 lines (87 loc) · 3.27 KB
/
setup.sh
File metadata and controls
executable file
·92 lines (87 loc) · 3.27 KB
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
#!/usr/bin/env bash
platform=$(uname)
if [[ $# -eq 0 ]]; then
echo "Usage: $(basename $0) install|uninstall|upgrade"
exit 1
fi
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root." >&2
exit 1
fi
if [[ "$platform" == "Linux" ]]; then
bindir="/usr/local/bin"
resdir="/usr/local/share/BOOTDISK"
homedir="$(getent passwd $SUDO_USER | cut -d: -f6)"
apphome="$homedir/.local/share/applications"
elif [[ "$platform" == "Darwin" ]]; then
bindir="/opt/local/bin"
resdir="/opt/local/share/BOOTDISK"
else
echo "Unsupported platform detected."
exit 1
fi
if [[ "$1" == "install" ]]; then
echo "Installing scripts and resources..."
install -d $bindir
install -d $resdir/Support
install -m 755 bootdisk.sh $bindir/bootdisk
if [[ "$platform" == "Darwin" ]]; then
install -m 755 Support/click_ignore.scpt $resdir/Support
elif [[ "$platform" == "Linux" ]]; then
install -m 755 Support/bootdisk.desktop "$apphome"
chown $SUDO_USER:$SUDO_USER "$apphome/bootdisk.desktop"
if [[ -d "$homedir/snap/firefox" ]]; then
install -d /usr/share/doc/bootdisk
install -m 644 Support/About.html /usr/share/doc/bootdisk
else
install -m 644 Support/About.html $resdir/Support
fi
fi
install -m 755 Support/*.sh $resdir/Support
install -m 755 Support/modtime.py $resdir/Support
install -m 644 Support/doslfn.zip $resdir/Support
install -m 644 Support/About.txt $resdir/Support
install -m 644 Support/usb-icon.png $resdir/Support
rsync -r --chmod=u=rwx,go=rx FreeDOS $resdir
rsync -r --chmod=u=rwx,go=rx MS-DOS $resdir
rsync -r --chmod=u=rwx,go=rx Windows $resdir
chmod o+w $resdir/Support
echo "Finished."
elif [[ "$1" == "uninstall" ]]; then
echo "Removing scripts and resources..."
rm $bindir/bootdisk
rm -r $resdir
if [[ "$platform" == "Linux" ]]; then
rm "$apphome/bootdisk.desktop"
rm -rf /usr/share/doc/bootdisk
fi
echo "Finished."
elif [[ "$1" == "upgrade" ]]; then
echo "Upgrading to current version..."
rm $bindir/bootdisk
rm -f $resdir/Support/About.*
rm $resdir/Windows/windowstogo.sh
find $resdir -type f -name '*disk.sh' -delete
find $resdir -type d -name 'Sectors' -prune -exec rm -rf {} \;
install -m 755 bootdisk.sh $bindir/bootdisk
install -m 755 FreeDOS/freedosdisk.sh $resdir/FreeDOS
install -m 755 MS-DOS/msdosdisk.sh $resdir/MS-DOS
install -m 755 Windows/*.sh $resdir/Windows
install -m 755 Support/*.sh $resdir/Support
install -m 644 Support/usb-icon.png $resdir/Support
install -m 644 Support/About.txt $resdir/Support
if [[ "$platform" == "Linux" ]]; then
install -m 755 Support/bootdisk.desktop "$apphome"
chown $SUDO_USER:$SUDO_USER "$apphome/bootdisk.desktop"
if [[ -d "$homedir/snap/firefox" ]]; then
rm -rf /usr/share/doc/bootdisk
install -d /usr/share/doc/bootdisk
install -m 644 Support/About.html /usr/share/doc/bootdisk
else
install -m 644 Support/About.html $resdir/Support
fi
fi
echo "Finished."
else
echo "Invalid option entered. Please try again."
fi