123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #!/usr/bin/env sh
- set -e
- hosts()
- {
- host="/etc/hosts.main"
- yes="/etc/hosts.yes"
- if [ ! -s "$yes" ]; then
- if [ -s "$host" ]; then
- while read line
- do
- echo $line >> /etc/hosts
- done < $host
- echo "yes" > $yes
- fi
- fi
- }
- process()
- {
- echo "$1 Startup Completed" > /share/process/$1
- }
- check()
- {
- path="process"
- if [ -n "$2" ];then
- path="$2"
- fi
- process="/share/$path/$1"
- while [ ! -s "$process" ]; do
- true
- done
- }
- share()
- {
- path=/share/lib/$2
- if [ ! -d "$path" ]; then
- mkdir -p "$path"
- fi
- cp -R $1/* $path
- }
- hadoop_mkdir()
- {
- dir=$(hadoop fs -ls / | grep $1 | wc -l)
- if [ $dir -eq 0 ] ;then
- for i in $@
- do
- hadoop fs -mkdir -p /$i
- done
- fi
- }
- load()
- {
- dir=/entrypoint/
- loop=$(ls -l $dir |awk '{print $9}')
- for i in $loop
- do
- source $dir$i
- done
- }
- start()
- {
- if [ -n "$1" ];then
- start="start_$@"
- echo "$start"
- status=`$start`
- echo $status
- netstat -apn
- process $1
- fi
- }
- stop()
- {
- if [ -n "$1" ];then
- stop="stop_$@"
- echo "$stop"
- status=`$stop`
- echo $status
- rm -rf /share/process/$1
- fi
- }
- monit()
- {
- if [ -n "$1" ];then
- monit="monit_$@"
- status=`$monit`
- fi
- }
- load
- hosts
- start $@
- if [ "$2" == "exit" ]; then
- exit 0
- fi
- trap "stop $1" HUP INT QUIT ABRT KILL ALRM TERM EXIT
- while true
- do
- monit $@
- sleep 10
- done
- #exec sh
- exit 0
|