Created
January 12, 2012 18:00
-
-
Save dnpp73/1602083 to your computer and use it in GitHub Desktop.
boxnya utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 変数類の定義 | |
python27="/Path/to/python2.7" | |
boxnya="/Path/to/Boxnya/src/boxnya.py" | |
option="--noegosearch -q" | |
users=("DNPP" "dnpp73" "hoge" "fuga" "piyo") | |
stdOut="/Path/to/Boxnya/log/" | |
# boxnya の実行 | |
cd `dirname ${boxnya}` | |
for user in ${users[@]} ; do | |
${python27} ${boxnya} ${option} ${user} 1>>${stdOut}${user}/stdOut.txt 2>&1 & | |
done | |
# 後片付け用関数。ただし bash 依存? | |
clear_boxnya_jobs() | |
{ | |
# kill %1 %2 %3 みたいな感じ | |
i=0 | |
while [ ${i} -ne ${#users[*]} ] ; do | |
i=`expr ${i} + 1` | |
kill %${i} | |
done | |
return 0 | |
} | |
# 後片付けの実行 | |
trap "clear_boxnya_jobs;exit" 1 2 3 15 | |
# とりあえずループ | |
while /bin/true | |
do | |
sleep 10 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
name="boxnya" | |
user="hoge" | |
pidfile="/var/run/boxnya.pid" | |
prog="/Path/to/boxnya/shellscript" | |
start() { | |
echo -n $"Starting $name: " | |
/sbin/start-stop-daemon --start --background --make-pidfile --pidfile $pidfile --chuid $user --user $user --exec $prog | |
RETVAL=$? | |
echo | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping $name: " | |
/sbin/start-stop-daemon --stop --oknodo --pidfile $pidfile --chuid $user --user $user | |
RETVAL=$? | |
echo | |
return $RETVAL | |
} | |
restart() { | |
stop | |
start | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart|reload|force-reload) | |
restart | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart|reload|force-reload}" | |
exit 1 | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment