| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #!/bin/bash
- # info: restart ftp service
- # options: NONE
- #
- # The function tells ftp server to reread its configuration.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Includes
- source $VESTA/func/main.sh
- source $VESTA/conf/vesta.conf
- send_email_report() {
- send_mail="$VESTA/web/inc/mail-wrapper.php"
- email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
- email=$(echo "$email" | cut -f 2 -d "'")
- tmpfile=$(mktemp)
- subj="$(hostname): $FTP_SYSTEM restart failed"
- /etc/init.d/$FTP_SYSTEM configtest >> $tmpfile 2>&1
- /etc/init.d/$FTP_SYSTEM restart >> $tmpfile 2>&1
- cat $tmpfile | $send_mail -s "$subj" $email
- rm -f $tmpfile
- }
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Schedule restart
- if [ "$1" = 'scheduled' ]; then
- echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe
- exit
- fi
- if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
- echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe
- exit
- fi
- if [ -z "$FTP_SYSTEM" ]; then
- exit
- fi
- # Restart system
- /etc/init.d/$FTP_SYSTEM restart >/dev/null 2>&1
- if [ $? -ne 0 ]; then
- send_email_report
- echo "Error: $FTP_SYSTEM restart failed"
- exit $E_RESTART
- fi
- # Update restart queue
- if [ -e "$VESTA/data/queue/restart.pipe" ]; then
- sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe
- fi
- #----------------------------------------------------------#
- # Vesta #
- #----------------------------------------------------------#
- exit
|