2016-11-17 13:49:13 -05:00
|
|
|
installdir="$HOME/.eclipsesettings"
|
|
|
|
if test ! -d $installdir; then
|
|
|
|
mkdir $installdir
|
|
|
|
if test ! -d $installdir; then
|
|
|
|
echo fail:cannot create $installdir
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
cat > $installdir/bootstrap.sh <<-\EOF
|
|
|
|
#!/bin/sh
|
|
|
|
installdir="$HOME/.eclipsesettings"
|
|
|
|
proxytmp=$installdir/proxy.b64
|
|
|
|
success=false
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
rm -f $installdir/bootstrap.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
trap 'cleanup' EXIT
|
|
|
|
|
|
|
|
parent_is_not_orphan () {
|
|
|
|
parent=`ps -ef|awk '$2=='$$'{print $3}'`
|
|
|
|
let parent=$parent+0
|
|
|
|
if [[ $parent -eq 1 ]]; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
do_check() {
|
|
|
|
java_vers=`java -version 2>&1`
|
2016-12-01 22:33:07 -05:00
|
|
|
major=`expr "$java_vers" : "java version \"\([0-9]*\)\.[0-9]*.*\""`
|
|
|
|
minor=`expr "$java_vers" : "java version \"[0-9]*\.\([0-9]*\).*\""`
|
|
|
|
if test "$major" -ge 2 -o "$minor" -ge 8; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
echo "fail:invalid java version $major.$minor; must be >= 1.8"
|
|
|
|
return
|
2016-11-17 13:49:13 -05:00
|
|
|
fi
|
|
|
|
case "`uname`" in
|
|
|
|
Linux)
|
|
|
|
osname="linux";
|
|
|
|
osarch=`uname -m`;
|
|
|
|
proxydir=$installdir/proxy;
|
|
|
|
plugins=$proxydir/plugins;;
|
|
|
|
Darwin)
|
|
|
|
osname="macosx";
|
|
|
|
osarch=`uname -m`;
|
|
|
|
proxydir=$installdir/Proxy.app;
|
|
|
|
plugins=$proxydir/Contents/Eclipse/plugins;;
|
|
|
|
*)
|
2016-12-01 22:33:07 -05:00
|
|
|
echo fail:system not supported;
|
|
|
|
return;;
|
2016-11-17 13:49:13 -05:00
|
|
|
esac
|
|
|
|
proxy=no
|
|
|
|
if test -d $proxydir; then
|
|
|
|
bundle="org.eclipse.remote.proxy.server.core_$1.jar"
|
|
|
|
if test -f $plugins/$bundle; then
|
|
|
|
proxy=yes
|
|
|
|
else
|
|
|
|
mv $proxydir $proxydir.pre_$1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo ok:$proxy/$osname/$osarch
|
|
|
|
}
|
|
|
|
|
|
|
|
do_download() {
|
|
|
|
dd of=$proxytmp ibs=680 count=$1
|
|
|
|
IFS= read -r last
|
|
|
|
echo "$last" >> $proxytmp
|
|
|
|
base64 --decode < $proxytmp | tar zxf - > /dev/null 2>&1
|
|
|
|
if test $? -eq 0; then
|
|
|
|
echo ok
|
|
|
|
else
|
|
|
|
echo fail:download failed
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Start java in background so we can clean up after connection is dropped. The only way to tell if this
|
|
|
|
# has happened is to poll if ppid has changed to 1 (i.e. we no longer have a controlling terminal)
|
|
|
|
#
|
|
|
|
start_server() {
|
|
|
|
#debugoptions="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044,quiet=y"
|
|
|
|
|
|
|
|
java -cp $plugins/org.eclipse.equinox.launcher_1.3.200.v20160318-1642.jar \
|
|
|
|
$debugoptions \
|
|
|
|
org.eclipse.equinox.launcher.Main \
|
|
|
|
-application org.eclipse.remote.proxy.server.core.application \
|
|
|
|
-noExit 0<&0 &
|
|
|
|
|
|
|
|
pid=$!
|
|
|
|
|
|
|
|
trap 'kill $pid; exit' HUP INT TERM
|
|
|
|
|
|
|
|
while parent_is_not_orphan; do
|
|
|
|
sleep 10
|
|
|
|
done
|
|
|
|
|
|
|
|
kill $pid
|
|
|
|
}
|
|
|
|
|
|
|
|
echo running
|
|
|
|
|
|
|
|
while read line arg; do
|
|
|
|
case $line in
|
|
|
|
check) do_check $arg;;
|
|
|
|
download) do_download $arg;;
|
|
|
|
start) start_server;;
|
|
|
|
exit) break;;
|
|
|
|
*) echo fail:unrecognized command:$line; exit 1;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
exit 0
|
|
|
|
EOF
|
|
|
|
chmod 755 $installdir/bootstrap.sh
|
|
|
|
exec $installdir/bootstrap.sh
|