Skip to content

Commit 031b0df

Browse files
authored
Merge pull request #54 from projectOpenRAP/develop
Develop
2 parents 5627d7b + deffcee commit 031b0df

246 files changed

Lines changed: 117551 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+
apiserver/vendor

CDN/addContent.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
#### Scripto add content(teach kits for example) to flash
4+
5+
6+
start=128
7+
blocksize=512
8+
9+
#To update
10+
datafile_path=/var/www/HMLT/docs
11+
database_path=/var/www/api_server/
12+
13+
14+
mount_path=/tmp/mount
15+
16+
help ()
17+
{
18+
echo $0 "</absolute/path/to/data/files> <databasefile> <image_file> "
19+
echo "Will add the files in <path/to/data/files> to <img_file> and will also update the databasefile "
20+
exit -1
21+
}
22+
23+
24+
if [ $# -lt 3 ]
25+
then
26+
help
27+
fi
28+
29+
echo "Now coping all the contents in $1/ to $3 and will update database file $2"
30+
echo "Hit any key to continue.."
31+
32+
read
33+
34+
offset=`expr $start '*' $blocksize`
35+
36+
mkdir -p $mount_path
37+
38+
## First let us mount the img file..
39+
mount -o loop,offset=$offset $3 $mount_path
40+
41+
42+
## cp the contents
43+
cp $1/* $mount_path/$1
44+
45+
## copy the database files
46+
47+
cp $2 $mount_path/$database_path/
48+
49+
umount $mount_path
50+
51+
rmdir $mount_path
52+

CDN/devicemgmtserver

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sleep 2
2+
/usr/bin/python /opt/opencdn/devmgmt/file_upload/manage.py runserver 0.0.0.0:8008

CDN/modeChange.sh

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
#!/bin/bash
2+
# Script to move device from AP mode to client mode and vice-a-versa
3+
4+
5+
### Copy interfaces file for static config
6+
7+
static () {
8+
9+
cat << EOF > /etc/network/interfaces
10+
auto lo
11+
iface lo inet loopback
12+
13+
#auto eth0
14+
allow-hotplug eth0
15+
iface eth0 inet dhcp
16+
17+
18+
auto wlan0
19+
allow-hotplug wlan0
20+
iface wlan0 inet static
21+
address 192.168.0.1
22+
netmask 255.255.255.0
23+
EOF
24+
25+
}
26+
27+
## Copy interfaces file for dhcp config
28+
29+
dynamic_psk () {
30+
31+
cat << EOF > /etc/network/interfaces
32+
auto lo
33+
iface lo inet loopback
34+
35+
#auto eth0
36+
allow-hotplug eth0
37+
iface eth0 inet dhcp
38+
39+
auto wlan0
40+
allow-hotplug wlan0
41+
iface wlan0 inet dhcp
42+
wpa-psk "$PSK"
43+
wpa-ssid "$SSID"
44+
EOF
45+
46+
}
47+
48+
49+
dynamic_none () {
50+
51+
cat << EOF > /etc/network/interfaces
52+
auto lo
53+
iface lo inet loopback
54+
55+
#auto eth0
56+
allow-hotplug eth0
57+
iface eth0 inet dhcp
58+
59+
auto wlan0
60+
allow-hotplug wlan0
61+
iface wlan0 inet dhcp
62+
wpa-ssid "$SSID"
63+
wpa-key-mgmt NONE
64+
EOF
65+
66+
67+
}
68+
69+
hostapd_conf () {
70+
cat << EOF > /etc/hostapd/hostapd.conf
71+
interface=wlan0
72+
ssid=$SSID
73+
hw_mode=g
74+
channel=2
75+
ieee80211n=1
76+
auth_algs=1
77+
78+
EOF
79+
}
80+
81+
help () {
82+
echo ""
83+
echo "$0 hostmode <ssid> [<password>]|apmode <ssid>"
84+
echo ""
85+
86+
exit -1
87+
88+
}
89+
90+
stop_apmode()
91+
{
92+
93+
#stop few services
94+
/usr/sbin/service hostapd stop #if called second time, just to change the SSID
95+
/usr/sbin/service dnsmasq stop
96+
/usr/sbin/service dhcpcd stop
97+
/usr/sbin/service wpa_supplicant stop
98+
99+
#Kill manually triggered wpa_supplicant
100+
killall -15 wpa_supplicant # Stop any manually triggered process
101+
}
102+
103+
start_apmode()
104+
{
105+
106+
# restart networking
107+
/usr/sbin/service networking restart
108+
109+
# restart other services
110+
/usr/sbin/service hostapd start
111+
/usr/sbin/service dnsmasq start
112+
113+
# Enable services
114+
/bin/systemctl enable hostapd
115+
/bin/systemctl enable dnsmasq
116+
117+
}
118+
119+
120+
###Parse the commands
121+
122+
if [ "$1" == "apmode_restore" ] # hidden option to start AP mode with a file
123+
then
124+
125+
stop_apmode
126+
#update /etc/network/interfaces
127+
static
128+
129+
start_apmode
130+
131+
exit 0
132+
fi
133+
134+
if [ $# -lt 1 ]
135+
then
136+
help
137+
fi
138+
139+
if [ "$1" == "hostmode" ]
140+
then
141+
## move to hostmode
142+
## Stop hostapd, dhcpserver, dns server and dhcpclient (cleanup)
143+
144+
stop_apmode
145+
146+
SSID=$2
147+
if [ $# -eq 3 ]
148+
then
149+
PSK=$3
150+
dynamic_psk
151+
else
152+
dynamic_none
153+
fi
154+
155+
sync; sync; sync
156+
157+
sleep 2
158+
ifdown wlan0
159+
sleep 2
160+
ifup wlan0
161+
162+
echo Done...
163+
164+
165+
exit 0
166+
167+
168+
##Let us verify if connection was succefull
169+
STATUS=`cat /sys/class/net/wlan0/operstate`
170+
171+
if [ "$STATUS" == "up" ]
172+
then
173+
### put the /etc/networking/interfaces file back, so that across reload, the box
174+
### come back as AP
175+
static
176+
exit 0
177+
fi
178+
179+
##status not ok, we will start apmode again
180+
181+
$0 apmode_restore
182+
exit 0
183+
184+
185+
fi
186+
187+
if [ "$1" == "apmode" ]
188+
then
189+
190+
stop_apmode
191+
#update /etc/network/interfaces
192+
static
193+
#update hostapd.conf
194+
SSID=$2
195+
hostapd_conf
196+
start_apmode
197+
198+
exit 0
199+
fi
200+
201+
help

CDN/postpreinstall.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## Save fles
2+
3+
files_saved="
4+
/opt/opencdn/rootfs_overlay/etc/hostapd/hostapd.conf
5+
/opt/opencdn/rootfs_overlay/var/www/ekstep/config_json/config.json
6+
"
7+
save_files()
8+
{
9+
echo "Saving files"
10+
11+
for i in $files_saved
12+
do
13+
cp $i /tmp
14+
done
15+
16+
}
17+
18+
restore_files()
19+
{
20+
echo "Restoring files"
21+
22+
for i in $files_saved
23+
do
24+
mv /tmp/`echo $i | awk -F/ '{print $NF}'` $i
25+
done
26+
}
27+
28+
post_install()
29+
{
30+
echo "Running post install scripts"
31+
restore_files
32+
exit 0
33+
34+
}
35+
36+
pre_install()
37+
{
38+
echo "Running pre install scripts"
39+
save_files
40+
41+
exit 0
42+
}
43+
44+
45+
if [ "$1" == "-post" ]
46+
then
47+
post_install
48+
fi
49+
50+
if [ "$1" == "-pre" ]
51+
then
52+
pre_install
53+
fi
54+
55+
echo "$0 <-post | -pre>"
56+
57+

CDN/profile.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"active_profile": "ekstep",
3+
"available_profiles": {
4+
"ekstep": {
5+
"accepted_extensions": [
6+
".ecar",
7+
".json"
8+
],
9+
"cdn_scripts_dir": "/opt/opencdn/CDN/",
10+
"cdn_url": "http://cdn.ekstep.com",
11+
"config_json_dir": "/var/www/ekstep/config_json/",
12+
"config_json_name": "config.json",
13+
"content_root": "/var/www/ekstep/ecar_files/",
14+
"json_dir": "/var/www/ekstep/json_dir/",
15+
"media_root": "/var/www/ekstep/",
16+
"profile_name": "ekstep",
17+
"server_root": "/opt/opencdn/devmgmt/file_upload/",
18+
"telemetry": "/var/www/ekstep/telemetry/",
19+
"unzip_content": "/var/www/ekstep/xcontent/",
20+
"unzip_contentdir_name": "xcontent",
21+
"usb_dir": "ecar_files",
22+
"usb_on_automount": "/media/"
23+
},
24+
"meghshala": {
25+
"accepted_extensions": [
26+
".data",
27+
".json"
28+
],
29+
"cdn_scripts_dir": "/opt/opencdn/CDN/",
30+
"cdn_url": "http://edge.meghshala.com",
31+
"config_json_dir": "/var/www/meghshala/config_json/",
32+
"config_json_name": "config.json",
33+
"content_root": "/var/www/meghshala/content/",
34+
"json_dir": "/var/www/meghshala/json_dir/",
35+
"media_root": "/var/www/meghshala/",
36+
"profile_name": "meghshala",
37+
"server_root": "/opt/opencdn/devmgmt/file_upload/",
38+
"telemetry": "/var/www/meghshala/telemetry/",
39+
"unzip_content": "/var/www/meghshala/content/",
40+
"unzip_contentdir_name": "content",
41+
"usb_dir": "data_files",
42+
"usb_on_automount": "/media/"
43+
},
44+
"pinut": {
45+
"accepted_extensions": [
46+
".mp4",
47+
".mov",
48+
".mp3",
49+
".png",
50+
".jpeg",
51+
".pdf"
52+
],
53+
"cdn_scripts_dir": "/opt/opencdn/CDN/",
54+
"cdn_url": "http://app.pinut.in",
55+
"config_json_dir": "/var/www/pinut_data/config_json/",
56+
"config_json_name": "config.json",
57+
"content_root": "/var/www/pinut_data/content/",
58+
"json_dir": "/var/www/pinut_data/json_dir/",
59+
"media_root": "/var/www/pinut_data/",
60+
"profile_name": "pinut",
61+
"server_root": "/opt/opencdn/devmgmt/file_upload/",
62+
"telemetry": "/var/www/pinut_data/telemetry/",
63+
"unzip_content": "/var/www/pinut_data/content/",
64+
"unzip_contentdir_name": "content",
65+
"usb_dir": "pinut_data",
66+
"usb_on_automount": "/media/"
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)