-
Notifications
You must be signed in to change notification settings - Fork 29
/
exroot.sh
85 lines (54 loc) · 1.33 KB
/
exroot.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
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
GRAY='\033[0;37m'
NC='\033[0m' # No Color
echo "Running as root..."
sleep 2
clear
### Update Packages ###
opkg update
sleep 2
## Install Some Package for USB Driver ###
opkg install kmod-usb-storage
sleep 2
opkg install kmod-usb-storage-uas
sleep 2
opkg install usbutils
sleep 2
opkg install block-mount kmod-fs-ext4 e2fsprogs parted
sleep 2
parted -s /dev/sda -- mklabel gpt mkpart extroot 2048s -2048s
sleep 2
### Configuring rootfs_data ###
DEVICE="$(sed -n -e "/\s\/overlay\s.*$/s///p" /etc/mtab)"
uci -q delete fstab.rwm
uci set fstab.rwm="mount"
uci set fstab.rwm.device="${DEVICE}"
uci set fstab.rwm.target="/rwm"
uci commit fstab
sleep 2
### Configuring extroot ###
DEVICE="/dev/sda1"
mkfs.ext4 -L extroot ${DEVICE}
sleep 5
eval $(block info ${DEVICE} | grep -o -e "UUID=\S*")
uci -q delete fstab.overlay
uci set fstab.overlay="mount"
uci set fstab.overlay.uuid="${UUID}"
uci set fstab.overlay.target="/overlay"
uci commit fstab
sleep 2
### Transferring data ###
mount ${DEVICE} /mnt
sleep 2
tar -C /overlay -cvf - . | tar -C /mnt -xf -
echo -e "${GREEN}Done ! Your Router Will Be reboot After 5 Seconds ... ${NC}"
echo "Powered By AmirHossein Choghaei"
sleep 5
reboot
rm exroot.sh 2> /dev/null