Skip to content

Commit

Permalink
fixes to shellinabox daemon control
Browse files Browse the repository at this point in the history
  • Loading branch information
greenbreakfast committed Oct 6, 2015
1 parent ce9f54b commit eea5323
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Returns an array of all installed console apps, information includes everything
Allows for control of the shellinabox daemon through ubus

##### Usage
Takes argument in following format `{"params":{"key":"value"}}
Takes argument in following format `{"params":{"key":"value"}}`

Possible Keys:
* Start
Expand Down
46 changes: 23 additions & 23 deletions rpcd/onion-console.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,48 +67,48 @@ ShellinaboxCtrl () {
# initialize json response object
json_init

# find the pids of any running shellinabox processes
pids=$(_getPids shellinabox ubus)

# count the number of processes
count=0
for pid in $pids
do
count=`expr $count + 1`
done

# check arguments for supported commands
for argument in $argumentString
do
if [ "$argument" == "-start" ]
then
# start the shellinabox daemon
Log "ShellinaboxCtrl:: Start the shellinabox daemon"
/usr/sbin/shellinaboxd -t -s "/:$(id -u):$(id -g):HOME:"'/bin/ash'

json_add_boolean "start" 1
# start the shellinabox daemon (if there are none running)
Log "ShellinaboxCtrl:: Start the shellinabox daemon, current count is $count"

if [ $count -eq 0 ]
then
json_add_boolean "start" 1
/usr/sbin/shellinaboxd -t -s "/:$(id -u):$(id -g):HOME:"'/bin/ash' &
else
json_add_boolean "start" 0
fi
elif [ "$argument" == "-check" ]
then
# check if the shellinabox daemon is running
Log "ShellinaboxCtrl:: Check for shellinabox daemon"

# find the processes and their pids
pids=$(_getPids shellinabox ubus)
Log "ShellinaboxCtrl:: found following pids: $pids"

json_add_string "pids" "$pids"

# count the number of processes
count=0
for pid in $pids
do
count=`expr $count + 1`
done

json_add_int "running" $count
elif [ "$argument" == "-stop" ]
then
# stop the shellinabox daemon
Log "ShellinaboxCtrl:: Stop the shellinabox daemon"

# find the pids
pids=$(_getPids shellinabox ubus)

# stop each of them
count=0
# stop each process
for pid in $pids
do
count=`expr $count + 1`
kill $pid
kill $pid >& /dev/null
done

json_add_int "stopped" $count
Expand Down

0 comments on commit eea5323

Please sign in to comment.