parent
70d370ba33
commit
831cfe3e9e
@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
#------------------------------------------------------------------------------
|
||||
# slimd
|
||||
# Copyright ©2009 Mir Calculate Ltd.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
stopslim() {
|
||||
killall X &>/dev/null
|
||||
killall -9 slim &>/dev/null
|
||||
rm -f /var/run/slim.lock
|
||||
exit
|
||||
}
|
||||
|
||||
waitrun() {
|
||||
while ! ps axo pid,cmd | grep $1 | grep -v grep &>/dev/null
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
workloop() {
|
||||
trap stopslim TERM
|
||||
sleep 3
|
||||
waitrun /usr/bin/X
|
||||
while true
|
||||
do
|
||||
# check is working X
|
||||
if ! ps axo pid,cmd | grep /usr/bin/X | grep -v grep &>/dev/null
|
||||
then
|
||||
kill -9 `cat /var/run/slim.lock` &>/dev/null
|
||||
rm -f /var/run/slim.lock
|
||||
/usr/bin/slim
|
||||
# waiting for run X
|
||||
waitrun /usr/bin/X
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
/usr/bin/slim && workloop &
|
||||
|
Loading…
Reference in new issue