-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdropbear.sh
executable file
·96 lines (85 loc) · 2.6 KB
/
dropbear.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
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
. ./vars.sh
DROP="2024.86" #Dropbear release number
ARCH="x86_64" #default arch
TARGET=$TOP/build
#location for the build, change this for your location
COMPILER="CC=musl-gcc"
#-----------------------------------------------------------------------
# first stuff happening here.
mkdir -p $TARGET
cd $TARGET
# a bunch of helpfull functions
#----------------------------------------------------------------------
function delete {
cd $TARGET
mv ../dropbear-$DROP.tar.bz2 ../../
#need to remove only dropbear stuff instead of everything
rm -rf usr/
rm -rf ../dropbear-$DROP/
cp ../../dropbear-$DROP.tar.bz2 ../dropbear-$DROP.tar.bz2
exit 1
}
function extract {
echo "[ extract dropbear ]"
cd $TARGET/..
tar -xvf dropbear-$DROP.tar.bz2
}
function build {
echo "[ building dropbear ]"
cd $TARGET/../dropbear-$DROP
./configure \
--enable-static \
--disable-syslog \
--enable-bundled-libtom \
--disable-lastlog \
--disable-utmp \
--disable-utmpx \
--disable-wtmp \
--disable-wtmpx \
--disable-zlib \
--disable-loginfunc \
--prefix=/usr/sbin/
#--disable-pututline \
#--disable-pututxline \
make -j8 $COMPILER #PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp"
}
function install {
echo "[ install dropbear ]"
cd $TARGET/../dropbear-$DROP
mkdir -pv $TARGET/usr/sbin/
cp dropbear $TARGET/usr/sbin/
cp dropbearkey $TARGET/usr/sbin/
cp dropbearconvert $TARGET/usr/sbin/
cp dbclient $TARGET/usr/sbin/
mkdir -pv $TARGET/etc/dropbear/
#cp ~/.ssh/id_rsa.pub $TARGET/etc/dropbear/authorized_keys
#cp ~/.ssh/id_rsa.pub $TARGET/root/authorized_keys
}
#----------------------------------------------------------------------
#process commandline arguments
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-d|-delete|-deleteall)
delete
shift; # past argument and value
;;
esac
done
#Download if nececairy, clean an unclean build
#wget doesnt download if its already there, so no if
#if [ ! -f $TARGET/../dropbear-$DROP.tar.bz2 ]; then
wget -c https://matt.ucc.asn.au/dropbear/releases/dropbear-$DROP.tar.bz2 -P $TARGET/..
#fi
if [ ! -f $TARGET/../dropbear-$DROP/README ]; then
extract
fi
if [ ! -f $TARGET/../dropbear-$DROP/dropbear ]; then
build
fi
if [ ! -f $TARGET/usr/sbin/dropbear ]; then
install
fi
echo "[ done ] files should be in" $TARGET