-
Notifications
You must be signed in to change notification settings - Fork 19
/
setupexample.sh
executable file
·48 lines (35 loc) · 1.48 KB
/
setupexample.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
#!/bin/bash
set +o verbose
# cd "(dirname "$0")"
# A bit crude but good for getting started
killall node mongod
rm -rf cordovaapp localhost3000 meteorapp
# First create the Meteor app
meteor create --example leaderboard meteorapp
cd meteorapp && meteor && cd .. &
# cd "(dirname "$0")"
# Then fetch it
sleep 3
rm -rf localhost3000
wget -E -H -k -K -p localhost:3000
mv localhost\:3000 localhost3000
cordova create cordovaapp
cd cordovaapp
mv www/index.html www/index-cordova-orig.html
cp -a ../localhost3000/* www/
cordova platform add android
IP=$(python -c 'import socket; s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); s.connect(("google.com", 80)); print s.getsockname()[0]')
echo "Your IP is probably $IP, let's use this for the app for now"
echo "Patching the Meteor code based on this http://blog.snowflax.com/meteor-on-mobile-device-using-phonegap/"
echo 73a74 > stream_client_url.patch
echo "> url = \"http://$IP:3000/\"; // Hack to connect to a specific Meteor server" >> stream_client_url.patch
echo 102a104 >> stream_client_url.patch
echo "> url = \"http://$IP:3000/\"; // Hack to connect to a specific Meteor server" >> stream_client_url.patch
sed -i.bak s/HelloCordova/HelloCordovaMeteor/g www/config.xml
cat stream_client_url.patch
patch -p0 $(find www|grep stream_client) < stream_client_url.patch
echo 'Now building the .apk'
cordova build
cordova compile android
# somehow I can't manage cordova to install stuff yet
adb install -r $(find .|grep apk$|grep -v unaligned)