Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10 | kardasa | 1 | #! /bin/bash |
2 | |||
3 | TEMPFILE=/tmp/screenlets.running.${USER}.tmp |
||
4 | |||
5 | if [ "${1}" = "stop" ]; then |
||
6 | #Wrtie all curently running screnlets to temp file excluding screenlets deamon and manager |
||
7 | |||
8 | ps aux | grep ${USER} | grep python | grep screenlets | sed '/screenlets-daemon.py/d; /screenlets-manager.py/d' | \ |
||
9 | awk '{printf $2","; n=10;while(++n<NF) printf $n " "; printf "%s\n",$NF}'> ${TEMPFILE} |
||
10 | |||
11 | #Read all file lines and close all running screenlets |
||
12 | |||
13 | echo "I'm closing all running screenlets" |
||
14 | while read line |
||
15 | do |
||
16 | PID=$(echo $line | awk -F, '{print $1}') |
||
17 | kill -9 $PID |
||
18 | done < ${TEMPFILE} |
||
19 | |||
20 | elif [ "${1}" = "start" ]; then |
||
21 | #Check if the temporary file exists |
||
22 | |||
23 | if (test -r ${TEMPFILE}) then |
||
24 | |||
25 | #Read the temporary file and lunch screenlets using their lunching cammand |
||
26 | |||
27 | echo "Starting screelets using a temporary list file" |
||
28 | while read line |
||
29 | do |
||
30 | COMMAND=$(echo $line | awk -F, '{print $2}') |
||
31 | $COMMAND &> /dev/null & |
||
32 | sleep 10 |
||
33 | done < ${TEMPFILE} |
||
34 | |||
35 | #Removing the temporary file |
||
36 | |||
37 | rm ${TEMPFILE} |
||
38 | |||
39 | else |
||
40 | echo "Seems there is no temp file or you have no rights to access it" |
||
41 | fi |
||
42 | else |
||
43 | echo "Usage ./screnlets-restart.sh start | stop" |
||
44 | fi |
||
45 |