Skip to content

Instantly share code, notes, and snippets.

@gbraad
Last active November 16, 2015 20:39
Show Gist options
  • Save gbraad/1830e1183d10be5b63e9 to your computer and use it in GitHub Desktop.
Save gbraad/1830e1183d10be5b63e9 to your computer and use it in GitHub Desktop.
On-device deployment of system-server

On-device deployment of system-server

Some issues still exist on device;

  • cp -r in local-file.js is not performed
  • application path becomes /data/local/haibu/apps/user/clock/app.js/[application]

Development environment at https://ide.c9.io/gbraad/makermade-systemserver does not suffer from these issues.

#!/bin/sh
echo Git clone
git clone https://github.com/makermade/app-server
git clone https://github.com/makermade/system-server
echo Install dependencies
cd app-server
npm install
cd ..
cd system-server
npm install
cd ..
#echo Set workaround configuration
#cd system-server
#cat << EOF > ./lib/config.json
#{
# "port" : 3000,
# "directories" : {
# "apps": "/data/local/wotapps/"
# }
#}
#EOF
#cd ..
echo Patch network listener
cd app-server
patch -p1 -i listen.patch
cd..
echo Prepare device
adb shell mount -o remount,rw /system
adb shell rm -rf /system/lib/node_modules/haibu
adb shell rm -f /system/bin/haibu
adb shell mkdir /system/lib/node_modules/haibu
adb shell rm -rf /system/lib/node_modules/sysd
adb shell rm -f /system/bin/sysd
adb shell mkdir /system/lib/node_modules/sysd
echo Install app-server to device
cd app-server
adb push bin/ /system/lib/node_modules/haibu/bin
adb push lib/ /system/lib/node_modules/haibu/lib
adb push node_modules /system/lib/node_modules/haibu/node_modules
adb push config/ /system/lib/node_modules/haibu/config/
adb push package.json /system/lib/node_modules/haibu/
adb shell ln -s /system/lib/node_modules/haibu/bin/haibu /system/bin/haibu
cd ..
echo Install system-server to device
cd system-server
adb push bin/ /system/lib/node_modules/sysd/bin
adb push lib/ /system/lib/node_modules/sysd/lib
adb push node_modules /system/lib/node_modules/sysd/node_modules
#adb shell ln -s /system/lib/node_modules/sysd/bin/sysd /system/bin/sysd
cd ..
echo Install system-wide dependencies
cd system-server
adb shell mkdir /system/lib/node_modules/express
adb push node_modules/express/ /system/lib/node_modules/express
cd ..
echo Copy test-apps (with workaround for on-device issues)
cd system-server
adb shell mkdir /data/local/wotapps
adb push wotapps/ /data/local/wotapps
adb push wotapps/clock /data/local/haibu/apps/user/clock/app.js
adb push wotapps/gpio /data/local/haibu/apps/user/gpio/app.js
adb push wotapps/dialer /data/local/haibu/apps/user/dialer/app.js
cd ..
echo ... done
echo Installed. Using adb shell start
echo (nodejs|node) /system/bin/haibu -a 0.0.0.0
echo (nodejs|node) /system/bin/sysd
echo and open http://localhost:3000/ on device
*** ./node_modules/haibu-carapace/lib/plugins/net.js 2015-11-03 13:58:47.851988768 +0800
--- ./node_modules/haibu-carapace/lib/plugins/net.js 2015-11-03 14:03:01.992934521 +0800
***************
*** 217,220 ****
// Setup the valid `nodeVersion` for all of the
// monkey patches to `require('net')`.
//
! module.exports._listen2.nodeVersion = '0.5.x || 0.6.x || 0.7.x || 0.8.x';
--- 217,220 ----
// Setup the valid `nodeVersion` for all of the
// monkey patches to `require('net')`.
//
! module.exports._listen2.nodeVersion = '0.5.x || 0.6.x || 0.7.x || 0.8.x || 0.10.x || 2.2.x';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment