Format shell scripts
Fix flags order
This commit is contained in:
parent
6c2e547808
commit
8b3e09d41c
24 changed files with 1487 additions and 1499 deletions
|
@ -30,49 +30,49 @@ PIDFILE=/var/run/$NAME.pid
|
|||
# and status_of_proc is working.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
start () {
|
||||
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \
|
||||
--make-pidfile --pidfile $PIDFILE --startas $DAEMON
|
||||
start() {
|
||||
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \
|
||||
--make-pidfile --pidfile $PIDFILE --startas $DAEMON
|
||||
}
|
||||
|
||||
stop () {
|
||||
# Send TERM after 5 seconds, wait at most 30 seconds.
|
||||
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
|
||||
rm -f $PIDFILE
|
||||
stop() {
|
||||
# Send TERM after 5 seconds, wait at most 30 seconds.
|
||||
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
|
||||
rm -f $PIDFILE
|
||||
}
|
||||
|
||||
case "${1:-''}" in
|
||||
'start')
|
||||
# start commands here
|
||||
echo -n "Starting $NAME: "
|
||||
start
|
||||
echo "Done."
|
||||
;;
|
||||
# start commands here
|
||||
echo -n "Starting $NAME: "
|
||||
start
|
||||
echo "Done."
|
||||
;;
|
||||
'stop')
|
||||
# stop commands here
|
||||
echo -n "Stopping $NAME: "
|
||||
stop
|
||||
echo "Done."
|
||||
;;
|
||||
# stop commands here
|
||||
echo -n "Stopping $NAME: "
|
||||
stop
|
||||
echo "Done."
|
||||
;;
|
||||
'restart')
|
||||
# restart commands here
|
||||
echo -n "Restarting $NAME: "
|
||||
stop
|
||||
start
|
||||
echo "Done."
|
||||
;;
|
||||
# restart commands here
|
||||
echo -n "Restarting $NAME: "
|
||||
stop
|
||||
start
|
||||
echo "Done."
|
||||
;;
|
||||
'force-reload')
|
||||
# reload commands here
|
||||
echo -n "Reloading $NAME: "
|
||||
stop
|
||||
start
|
||||
echo "Done."
|
||||
;;
|
||||
# reload commands here
|
||||
echo -n "Reloading $NAME: "
|
||||
stop
|
||||
start
|
||||
echo "Done."
|
||||
;;
|
||||
'status')
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
*) # no parameter specified
|
||||
echo "Usage: $SELF start|stop|restart|status"
|
||||
exit 1
|
||||
;;
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
*) # no parameter specified
|
||||
echo "Usage: $SELF start|stop|restart|status"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -1,49 +1,46 @@
|
|||
#!/bin/bash -xv
|
||||
|
||||
post_file() {
|
||||
#kill process after 30 minutes (360*5=30 minutes)
|
||||
max_retry=5
|
||||
retry_count=0
|
||||
#kill process after 30 minutes (360*5=30 minutes)
|
||||
max_retry=5
|
||||
retry_count=0
|
||||
|
||||
file_path="${1}"
|
||||
# Give us write permissions on the file to prevent problems if the user
|
||||
# uploads a read-only file.
|
||||
chmod +w "${file_path}"
|
||||
file_path="${1}"
|
||||
# Give us write permissions on the file to prevent problems if the user
|
||||
# uploads a read-only file.
|
||||
chmod +w "${file_path}"
|
||||
|
||||
#We must remove commas because CURL can't upload files with commas in the name
|
||||
# http://curl.haxx.se/mail/archive-2009-07/0029.html
|
||||
stripped_file_path=${file_path//','/''}
|
||||
mv "${file_path}" "${stripped_file_path}"
|
||||
file_path="${stripped_file_path}"
|
||||
filename="${file_path##*/}"
|
||||
#We must remove commas because CURL can't upload files with commas in the name
|
||||
# http://curl.haxx.se/mail/archive-2009-07/0029.html
|
||||
stripped_file_path=${file_path//','/''}
|
||||
mv "${file_path}" "${stripped_file_path}"
|
||||
file_path="${stripped_file_path}"
|
||||
filename="${file_path##*/}"
|
||||
|
||||
airtime_conf_path=/etc/airtime/airtime.conf
|
||||
airtime_conf_path=/etc/airtime/airtime.conf
|
||||
|
||||
#instance_path will look like 1/1384, for example
|
||||
http_path=$(grep base_url ${airtime_conf_path} | awk '{print $3;}')
|
||||
http_port=$(grep base_port ${airtime_conf_path} | awk '{print $3;}')
|
||||
|
||||
#instance_path will look like 1/1384, for example
|
||||
http_path=$(grep base_url ${airtime_conf_path} | awk '{print $3;}' )
|
||||
http_port=$(grep base_port ${airtime_conf_path} | awk '{print $3;}' )
|
||||
#post request url - http://bananas.airtime.pro/rest/media, for example
|
||||
url=http://
|
||||
url+=$http_path
|
||||
url+=:
|
||||
url+=$http_port
|
||||
url+=/rest/media
|
||||
|
||||
#post request url - http://bananas.airtime.pro/rest/media, for example
|
||||
url=http://
|
||||
url+=$http_path
|
||||
url+=:
|
||||
url+=$http_port
|
||||
url+=/rest/media
|
||||
api_key=$(grep api_key ${airtime_conf_path} | awk '{print $3;}')
|
||||
|
||||
|
||||
api_key=$(grep api_key ${airtime_conf_path} | awk '{print $3;}' )
|
||||
|
||||
# -f is needed to make curl fail if there's an HTTP error code
|
||||
# -L is needed to follow redirects! (just in case)
|
||||
until curl -fL --max-time 30 $url -u $api_key":" -X POST -F "file=@${file_path}"
|
||||
do
|
||||
retry_count=$[$retry_count+1]
|
||||
if [ $retry_count -ge $max_retry ]; then
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
# -f is needed to make curl fail if there's an HTTP error code
|
||||
# -L is needed to follow redirects! (just in case)
|
||||
until curl -fL --max-time 30 $url -u $api_key":" -X POST -F "file=@${file_path}"; do
|
||||
retry_count=$(($retry_count + 1))
|
||||
if [ $retry_count -ge $max_retry ]; then
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
}
|
||||
|
||||
post_file "${1}" &
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
#! /bin/bash
|
||||
|
||||
post_file() {
|
||||
file_path=${1}
|
||||
filename="${file_path##*/}"
|
||||
file_path=${1}
|
||||
filename="${file_path##*/}"
|
||||
|
||||
#kill process after 30 minutes (360*5=30 minutes)
|
||||
max_retry=10
|
||||
retry_count=0
|
||||
#kill process after 30 minutes (360*5=30 minutes)
|
||||
max_retry=10
|
||||
retry_count=0
|
||||
|
||||
until curl --max-time 30 http://localhost/rest/media -u 3188BDIMPJROQP89Z0OX: -X POST -F "file=@${file_path}" -F "name=${filename}"
|
||||
do
|
||||
retry_count=$[$retry_count+1]
|
||||
if [ $retry_count -ge $max_retry ]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
until curl --max-time 30 http://localhost/rest/media -u 3188BDIMPJROQP89Z0OX: -X POST -F "file=@${file_path}" -F "name=${filename}"; do
|
||||
retry_count=$(($retry_count + 1))
|
||||
if [ $retry_count -ge $max_retry ]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
post_file "${1}" &
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue