Compare commits

...

2 Commits

2 changed files with 92 additions and 0 deletions

23
Bash/formatFiles.sh Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
cmd_cat="/bin/cat"
cmd_rm="/bin/rm"
cmd_tr="/usr/bin/tr"
formatingFiles() {
for file in $(ls); do
formatFile $file
done
}
# Formating ASCII file to remove '\r' characters comming from Windows
formatFile() {
local file=$1
local tmp=$file.tmp
$cmd_tr -d '\r' < $file > $tmp
$cmd_cat $tmp > $file
$cmd_rm $tmp
}
formatingFiles

69
Bash/initScript.sh Normal file
View File

@ -0,0 +1,69 @@
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: scriptName
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $portmap
# Should-Stop: $portmap
# X-Start-Before: nis
# X-Stop-After: nis
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Short description of the script
# Description: description of the script
# a big one :)
### END INIT INFO
#######################
name="kage"
dirPath="/path/to/app"
#######################
sh="/bin/bash"
pidPath="$dirPath/$name.pid"
#######################
do_start() {
# TODO do start app
/bin/echo $! > $pidPath
}
do_stop() {
if [ -e $pidPath ]
then
pid=$(/bin/cat $pidPath)
kill $pid
rm $pidPath
fi
}
get_status() {
if [ -e $pidPath ] ; then
pid=$(/bin/cat $pidPath) ;
/bin/echo "$name is running with PID $pid" ;
else
/bin/echo "$name is stopped" ;
fi
}
case $1 in
start)
do_start
;;
stop)
do_stop
;;
restart)
do_stop
do_start
;;
status)
get_status
;;
*)
/bin/echo "Usage: $0 {start|stop|restart|status}"
exit 2
;;
esac