Skip to content

Instantly share code, notes, and snippets.

@dnpp73
Created January 12, 2012 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnpp73/1602083 to your computer and use it in GitHub Desktop.
Save dnpp73/1602083 to your computer and use it in GitHub Desktop.
boxnya utils
#!/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
#!/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