-
Notifications
You must be signed in to change notification settings - Fork 12
/
install.sh
executable file
·64 lines (58 loc) · 1.95 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
#!/usr/bin/env sh
DESTDIR=
BINDIR=/usr/bin
CONFDIR=/etc/all-ways-egpu
initServices() {
# check if using systemd or openrc
if [ -e "$(command -v systemctl)" ]; then
cp systemd/all-ways-egpu.service "${DESTDIR}"${CONFDIR}
cp systemd/all-ways-egpu-user.service "${DESTDIR}"${CONFDIR}
cp systemd/all-ways-egpu-boot-vga.service "${DESTDIR}"${CONFDIR}
cp systemd/all-ways-egpu-shutdown.service "${DESTDIR}"${CONFDIR}
cp systemd/all-ways-egpu-set-compositor.service "${DESTDIR}"${CONFDIR}
cp all-ways-egpu-reenable.desktop "${DESTDIR}"${CONFDIR}
else
if [ -e "$(command -v rc-status)" ]; then
cp OpenRC/all-ways-egpu-openrc "${DESTDIR}"${CONFDIR}
cp OpenRC/all-ways-egpu-boot-vga-openrc "${DESTDIR}"${CONFDIR}
cp OpenRC/all-ways-egpu-set-compositor-openrc "${DESTDIR}"${CONFDIR}
fi
fi
}
case $1 in
install)
mkdir -p "${DESTDIR}"${BINDIR}
cp all-ways-egpu "${DESTDIR}"${BINDIR}
chmod +x "${DESTDIR}"${BINDIR}/all-ways-egpu
mkdir -p "${DESTDIR}"${CONFDIR}
initServices
cp all-ways-egpu.desktop "${DESTDIR}"/usr/share/applications
;;
user-install)
set -- "${DESTDIR}"/home/*
for HD in "$@"; do
mkdir -p "$HD"/bin
cp all-ways-egpu "$HD"/bin
chmod +x "$HD"/bin/all-ways-egpu
if [ -x "$HD"/bin/all-ways-egpu ]; then
# Init services hard coded to first user path that is executable
sed -i 's,=all-ways-egpu,='"$HD"'\/bin\/all-ways-egpu,' systemd/*.service
sed -i 's,="all-ways-egpu",="'"$HD"'\/bin\/all-ways-egpu\",' OpenRC/*-openrc
if [ -e "$HD"/.local/share/applications ]; then
cp all-ways-egpu.desktop "$HD"/.local/share/applications
fi
if [ -e "$HD"/.bashrc ]; then
if ! cat "$HD"/.bashrc | grep -q PATH='.*$HOME/bin'; then echo 'export PATH="$HOME/bin:$PATH"' >> "$HD"/.bashrc; fi
fi
else
echo "Skipping directory ""$HD"" that is not executable"
rm -f "$HD"/bin/all-ways-egpu
fi
done
mkdir -p "${DESTDIR}"${CONFDIR}
initServices
;;
uninstall)
all-ways-egpu uninstall
;;
esac