This repository has been archived by the owner on Dec 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-webint-prstip.sh
86 lines (72 loc) · 1.89 KB
/
install-webint-prstip.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
#!/usr/bin/env bash
# Copyright (c) 2023 rM-self-serve
# SPDX-License-Identifier: MIT
prstip_sha256sum='7cf7d81d7a5196fd36711b4371255edda82f5f2bdc16a626f8b8aa1ade923b41'
release='v2.0'
installfile='./install-webint-prstip.sh'
pkgname='webinterface-persist-ip'
localbin='/home/root/.local/bin'
binfile="${localbin}/${pkgname}"
aliasfile="${localbin}/webint-prstip"
remove_installfile() {
read -r -p "Would you like to remove installation script? [y/N] " response
case "$response" in
[yY][eE][sS] | [yY])
printf "Exiting installer and removing script\n"
[[ -f $installfile ]] && rm $installfile
;;
*)
printf "Exiting installer and leaving script\n"
;;
esac
}
echo "${pkgname} ${release}"
echo "Ensure the web interface is internally accessible after disconnecting the usb cable."
echo ''
echo "This program will be installed in ${localbin}"
echo "${localbin} will be added to the path in ~/.bashrc if necessary"
echo ''
read -r -p "Would you like to continue with installation? [y/N] " response
case "$response" in
[yY][eE][sS] | [yY])
echo "Installing ${pkgname}"
;;
*)
remove_installfile
exit
;;
esac
mkdir -p $localbin
case :$PATH: in
*:$localbin:*) ;;
*) echo "PATH=\"${localbin}:\$PATH\"" >>/home/root/.bashrc ;;
esac
pkg_sha_check() {
if sha256sum -c <(echo "$prstip_sha256sum $binfile") >/dev/null 2>&1; then
return 0
else
return 1
fi
}
sha_fail() {
echo "sha256sum did not pass, error downloading ${pkgname}"
echo "Exiting installer and removing installed files"
[[ -f $binfile ]] && rm $binfile
remove_installfile
exit
}
[[ -f $binfile ]] && rm $binfile
wget "https://github.com/rM-self-serve/${pkgname}/releases/download/${release}/${pkgname}" \
-O "$binfile"
if ! pkg_sha_check; then
sha_fail
fi
chmod +x $binfile
ln -s $binfile $aliasfile
echo ""
echo "Finished installing ${pkgname}"
echo ""
echo "To use ${pkgname}, run:"
echo "$ webint-prstip apply"
echo ""
remove_installfile