Skip to content

Commit ac85e0f

Browse files
author
hastmu
committed
first install
1 parent 9b7c941 commit ac85e0f

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

install.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
# check requirements
4+
declare -A BINS
5+
BINS["id"]=0
6+
BINS["wget"]=0
7+
BINS["touch"]=0
8+
BINS["stat"]=0
9+
BINS["avahi-browse"]=0
10+
BINS["cat"]=0
11+
BINS["sed"]=0
12+
BINS["grep"]=0
13+
BINS["cut"]=0
14+
BINS["["]=0
15+
16+
declare -A FOUND
17+
for pitem in ${PATH//:/ }
18+
do
19+
for item in ${!BINS[@]}
20+
do
21+
if [ -x "${pitem}/${item}" ]
22+
then
23+
BINS[${item}]="${pitem}/${item}"
24+
fi
25+
done
26+
done
27+
28+
#declare -p BINS
29+
notfound=0
30+
echo "- check dependencies..."
31+
for item in ${!BINS[@]}
32+
do
33+
if [ "${BINS[${item}]}" = "0" ]
34+
then
35+
echo "! not found: ${item}"
36+
notfound=1
37+
fi
38+
done
39+
[ ${notfound} -eq 1 ] && exit 1
40+
41+
TARGET="/usr/local/bin/apt-proxy-detect.sh"
42+
# download latest
43+
echo "- download latest to: ${TARGET}"
44+
wget -q -O "${TARGET}" https://raw.githubusercontent.com/hastmu/apt-proxy-detect/main/apt-proxy-detect.sh
45+
if [ $? -ne 0 ]
46+
then
47+
echo "- download failed."
48+
[ -x "${TARGET}" ] && rm -f "${TARGET}"
49+
exit 1
50+
fi
51+
echo "- set permissions to a+rx"
52+
chmod a+rx "${TARGET}"
53+
54+
# install apt conf
55+
NAME="apt-proxy-detect"
56+
echo "Acquire::http::ProxyAutoDetect \""${TARGET}"\";" > /etc/apt/apt.conf.d/30${NAME}.conf
57+
echo "- create/updating /etc/apt/apt.conf.d/30${NAME}.conf"
58+
59+
60+

0 commit comments

Comments
 (0)