-
Notifications
You must be signed in to change notification settings - Fork 6
/
aakash.sh
166 lines (135 loc) · 6.67 KB
/
aakash.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/system/bin/sh
export bin=/system/bin
export PATH=$bin:/usr/bin:/usr/sbin:/bin:/usr/local/bin:$PATH
export TERM=linux
export HOME=/root
### aakash programming lab
export MNT=/data/local/linux
export EG=/data/example
export SDCARD=/mnt/sdcard/APL
export WWW=/data/local/linux/var/www/html
### abt
export MNTG=/data/local/abt
### ipython
export MNTI=/data/local/ipy
APL=1
ABT=1
IPY=1
function startServicesAPL
{
# mounting essential file systems to chroot
busybox mount -t proc proc $MNT/proc
busybox mount -o bind /dev $MNT/dev
busybox mount -t sysfs sysfs $MNT/sys
busybox chroot $MNT /bin/bash -c "mount /dev/pts"
busybox chroot $MNT /bin/bash -c "chown -R www-data.www-data /var/www/"
busybox chroot $MNT /bin/bash -c "chmod -R a+x /usr/lib/cgi-bin"
# cleaning and starting apache
busybox chroot $MNT /bin/bash -c "rm /dev/null"
busybox chroot $MNT /bin/bash -c "rm /var/run/apache2/*"
busybox chroot $MNT /bin/bash -c "rm /var/run/apache2.pid"
busybox chroot $MNT /bin/bash -c "service apache2 stop"
busybox chroot $MNT /bin/bash -c "service apache2 start"
busybox chroot $MNT /bin/bash -c "chmod 777 /var/www/html/c/exbind/.open_file.c"
busybox chroot $MNT /bin/bash -c "chmod 777 /var/www/html/cpp/exbind/.open_file.cpp"
busybox chroot $MNT /bin/bash -c "chmod 777 /var/www/html/python/exbind/.open_file.py"
busybox chroot $MNT /bin/bash -c "chmod 777 /var/www/html/scilab/exbind/.open_file.cde"
# running shellinaboxd, sb_manage and Xvfb
busybox chroot $MNT /bin/bash -c "shellinaboxd --localhost-only -t -s /:www-data:www-data:/:true &"
busybox chroot $MNT /bin/bash -c "rm /tmp/.X0-*"
busybox chroot $MNT /bin/bash -c "nohup Xvfb :0 -screen 0 640x480x24 -ac < /dev/null > Xvfb.out 2> Xvfb.err &"
if [ ! -d ${SDCARD} ] || [ ! -d ${WWW} ] || [ ! -d ${EG} ]
then
busybox mkdir -p ${SDCARD}/c/code
busybox mkdir -p ${WWW}/c/code
busybox mkdir -p ${EG}/c
busybox mkdir -p ${SDCARD}/cpp/code
busybox mkdir -p ${WWW}/cpp/code
busybox mkdir -p ${EG}/cpp
busybox mkdir -p ${SDCARD}/python/code
busybox mkdir -p ${WWW}/python/code
busybox mkdir -p ${EG}/python
busybox mkdir -p ${SDCARD}/scilab/code
busybox mkdir -p ${WWW}/scilab/code
busybox mkdir -p ${EG}/scilab
busybox mkdir -p ${SDCARD}/scilab/image
busybox mkdir -p ${WWW}/scilab/image
fi
busybox chroot /data/local/linux /bin/bash -c "nohup python /root/sb_manage.py &>'/dev/null'&"
busybox mount -o bind ${SDCARD}/c/code ${WWW}/c/code
busybox mount -o bind ${SDCARD}/cpp/code ${WWW}/cpp/code
busybox mount -o bind ${SDCARD}/python/code ${WWW}/python/code
busybox mount -o bind ${SDCARD}/scilab/code ${WWW}/scilab/code
busybox mount -o bind ${SDCARD}/scilab/image ${WWW}/scilab/image
busybox mount -o bind ${EG}/c ${WWW}/c/exbind
busybox mount -o bind ${EG}/cpp ${WWW}/cpp/exbind
busybox mount -o bind ${EG}/python ${WWW}/python/exbind
busybox mount -o bind ${EG}/scilab ${WWW}/scilab/exbind
}
####################################################################################################
while true
do
if [ $(mount | busybox grep /mnt/sdcard |busybox wc -l) -eq 2 ]
then
busybox mkdir -p $MNT $MNTG $MNTI
if [ -f /mnt/sdcard/apl.img ] && [ $APL -eq 1 ]
then
busybox mount -o loop /mnt/sdcard/apl.img /data/local/linux
startServicesAPL
APL=0
elif [ -f /mnt/extsd/apl.img ] && [ $APL -eq 1 ]
then
busybox mount -o loop /mnt/extsd/apl.img /data/local/linux
startServicesAPL
APL=0
fi
##############################################################
if [ -f /mnt/sdcard/abt.img ] && [ $ABT -eq 1 ]
then
# mounting essential file systems to chroot for ABT
busybox mount -o loop /mnt/sdcard/abt.img $MNTG
busybox mount -t proc proc $MNTG/proc
busybox mount -o bind /dev $MNTG/dev
busybox mount -t sysfs sysfs $MNTG/sys
busybox chroot $MNTG /bin/bash -c "mount /dev/pts"
busybox chroot $MNTG /bin/bash -c "source /root/.bashrc"
#busybox chroot /data/local/abt /bin/bash -c "python /root/ABTcore/abtstart &> '/dev/null' &"
busybox chroot ${MNTG} /bin/bash -c "/root/ABTcore/abtstart"
ABT=0
elif [ -f /mnt/extsd/abt.img ] && [ $ABT -eq 1 ]
then
# mounting essential file systems to chroot for ABT
busybox mount -o loop /mnt/extsd/abt.img $MNTG
busybox mount -t proc proc $MNTG/proc
busybox mount -o bind /dev $MNTG/dev
busybox mount -t sysfs sysfs $MNTG/sys
busybox chroot $MNTG /bin/bash -c "mount /dev/pts"
busybox chroot $MNTG /bin/bash -c "source /root/.bashrc"
#busybox chroot /data/local/abt /bin/bash -c "python /root/ABTcore/abtstart &> '/dev/null' &"
busybox chroot ${MNTG} /bin/bash -c "/root/ABTcore/abtstart"
ABT=0
fi
###############################################################
if [ -f /mnt/sdcard/ipy.img ] && [ $IPY -eq 1 ]
then
busybox mount -o loop /mnt/sdcard/ipy.img $MNTI
busybox mount -t proc proc $MNTI/proc
busybox mount -o bind /dev $MNTI/dev
busybox mount -t sysfs sysfs $MNTI/sys
busybox chroot $MNTI /bin/bash -c "mount /dev/pts"
busybox chroot $MNTI /bin/bash -c "/root/ipython/ipython.py notebook --no-mathjax --pylab=inline &"
IPY=0
elif [ -f /mnt/extsd/ipy.img ] && [ $IPY -eq 1 ]
then
busybox mount -o loop /mnt/extsd/ipy.img $MNTI
busybox mount -t proc proc $MNTI/proc
busybox mount -o bind /dev $MNTI/dev
busybox mount -t sysfs sysfs $MNTI/sys
busybox chroot $MNTI /bin/bash -c "mount /dev/pts"
busybox chroot $MNTI /bin/bash -c "/root/ipython/ipython.py notebook --no-mathjax --pylab=inline &"
IPY=0
fi
exit 0
fi
sleep 1
done