-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_v1.sh
More file actions
88 lines (66 loc) · 2.42 KB
/
install_v1.sh
File metadata and controls
88 lines (66 loc) · 2.42 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
#!/bin/sh
export PATH=/opt/sbin:/opt/bin:$PATH
URL=http://ndm.zyxmon.org/binaries/keenetic/installer/
echo "Entware-ng installation started"
# check /opt already mounted
grep -q /opt /proc/mounts && echo "/opt already mounted" && exit 0
# make dir "opt" on the drive root
mkdir -p /media/DISK_A1/opt
[ ! -d "/media/DISK_A1/opt" ] && echo "cannot create /opt folder on hdd" && exit 0
# mount /opt (bind only)
mount -o bind "/media/DISK_A1/opt" /opt
if [ $? -ne 0 ] ; then
echo "Mount /media/DISK_A1/opt to /opt FAILED! WTF?"
exit 1
fi
echo "Info: Creating folders..."
for folder in bin etc/init.d etc/firewall.d lib/opkg lib/modules/current sbin share tmp usr var/log var/lock var/run
do
if [ -d "/opt/$folder" ]
then
echo "Warning: Folder /opt/$folder exists! If something goes wrong please clean /opt folder and try again."
else
mkdir -p /opt/$folder
fi
done
# full access for /opt/tmp & /var/lock may be needed in multiuser environment
chmod 777 "/opt/tmp"
chmod 777 "/opt/var/lock"
dl () {
# $1 - URL to download
# $2 - place to store
# $3 - 'x' if should be executable
echo -n "Downloading $2... "
wget -q $1 -O $2
if [ $? -eq 0 ] ; then
echo "success!"
else
echo "failed!"
exit 1
fi
[ -z "$3" ] || chmod +x $2
}
echo "Info: Deploying opkg package manager..."
dl $URL/opkg /opt/bin/opkg x
dl $URL/opkg.conf /opt/etc/opkg.conf
echo "Info: Basic packages installation..."
opkg update
opkg install opt-ndmsv1 busybox-zyx dropbear
mkdir -p /opt/etc/dropbear/authorized_keys
chmod 600 /opt/etc/dropbear/authorized_keys
mkdir -p /media/DISK_A1/system/bin
dl $URL/ext_init.sh /media/DISK_A1/system/bin/ext_init.sh x
dl $URL/ext_firewall.sh /media/DISK_A1/system/bin/ext_firewall.sh x
SWAPFILE="/opt/.swapfile"
echo "Creating swap file. Please wait..."
dd if=/dev/zero of=$SWAPFILE bs=1048576 count=128
sync
mkswap $SWAPFILE 2> /dev/null
echo "Starting Entware ...."
/opt/etc/init.d/rc.unslung start
cat << EOF
Поздравляем! Если скрипт не выдал ошибок, то сиcтема пакетов Entware-ng успешно установлена.
Нашли ошибку - сообщите на форуме http://forums.zyxmon.org/viewforum.php?f=5
Для установки пакетов используйте команду 'opkg install <pkg_name>'.
Если Вам не нужен своп файл, переименуйте /opt/etc/init.d/S01swap в /opt/etc/init.d/K01swap.
EOF