#!/bin/sh
PATH=$PATH:/bin:/sbin

if [ -f "/bin/SdkLauncher" ] && pgrep SdkLauncher; then
    echo "Terminating SdkLaunchers..."
    killall -15 SdkLauncher
    # give them some time to die
    sleep 1
    echo "Killing SdkLaunchers..."
    killall -9 SdkLauncher
fi

export pid=$$
echo "Terminating everything...".
kill -15 `ps afx -o pid= | grep -v "^[ ]*1$" | grep -v  "^[ ]*${pid}$" | grep -v  "^[ ]*${PPID}$"`
# give them some time to die
sleep 1
echo "Killing everything..."
kill -9 `ps afx -o pid= | grep -v "^[ ]*1$" | grep -v  "^[ ]*${pid}$" | grep -v  "^[ ]*${PPID}$"`

echo "syncing filesystems..."
sync
