forked from downwa/ar2dscript
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun
More file actions
executable file
·67 lines (56 loc) · 2.05 KB
/
Copy pathrun
File metadata and controls
executable file
·67 lines (56 loc) · 2.05 KB
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
#!/bin/sh
# Startup script for unix-like Operating Systems. Need to create a Windows batch file too...
# Module dependencies
MODS="colors watchr path fs vm websocket process crypto fibers yauzl http path os cheerio"
# Possible module paths, else we expect node_modules in current working directory.
MPS="/usr/lib/node_modules /usr/local/lib/node_modules /usr/local/lib/node"
# NOTE: Windows, try %appdata%\npm (C:\Users\[Username]\AppData\Roaming\npm)
# NOTE: Also try using npm config get prefix (which returns /usr on Debian Jessie)
for p in $MPS; do
[ -d "$p" ] && MODSPATH="$p" && break
done
uid=$(id -u)
[ "$uid" != "0" ] && {
echo "Restarting as root..."
exec sudo "$0"
}
which bc >/dev/null || apt-get -y install bc
NODE=$(which node 2>/dev/null || which nodejs 2>/dev/null)
nodever=$($NODE --version 2>/dev/null | sed -e 's/v/((((/g' -e 's/\./)*100)+/g' | bc)
[ "$nodever" = "" -o "$NODE" = "" ] && nodever=0
if [ "$nodever" -le "1025" ]; then
which apt-get >/dev/null || {
echo "apt-get not supported. Use another method to install nodejs, then try again."
exit 1
}
which curl >/dev/null || apt-get -y install curl
echo "Installing new nodejs (nodever=$nodever)"
curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs || {
echo "Install failed. Exiting."
exit
}
fi
echo "Checking for modules to install..."
if [ -d "$MODSPATH" ]; then
export NODE_PATH=$MODSPATH
fi
for mod in $MODS; do
[ ! -d "node_modules/$mod" -a ! -d "$NODE_PATH/$mod" ] && npm install "$mod"
done
# DS="/sdcard/backups/apps/DroidScript_1.15.apk"
#DS="/sdcard/backups/apps/DroidScript_135a9.apk"
DS="/sdcard/backups/apps/"
# Examples for specifying DroidScript to use:
# Latest: DS="/sdcard/backups/apps/"
# Target: DS="/sdcard/backups/apps/DroidScript_1.15.apk"
export DS
while [ true ]; do
echo "Starting ar2dscript server..."
"$NODE" ./serve/main.js || {
echo "Terminated with error code: $?"
sleep 30
grep -q '"debug":true' serve/config.json && { sleep 300; } || reboot # For deployed devices
}
sleep 1
done