CryptoJones icon

reboot.sh

CryptoJones | PRO | 03/02/22 05:39:27 PM UTC (Edited) | 0 ⭐ | 1178 👁️ | Never ⏰ | []
Bash |

530 B

|

None

|

0 👍

/

0 👎

#!/bin/bash
HOST=`echo $HOSTNAME | sed -e 's/\(.*\)/\L\1/'`
CURRENTDATE=`date +"%Y-%m-%d %T" | sed 's/[[:space:]]//g' | sed 's/:/-/g'`
FILE="$HOST-$CURRENTDATE"
touch /home/ec2-user/rebooting-$FILE
aws s3 cp /home/ec2-user/rebooting-$FILE s3://s3-path/reboot/
FILEEXIST=$(aws s3 ls s3://s3-path/reboot/rebooting-$FILE)
 if [ -z "$FILEEXIST" ]; then
touch /home/ec2-user/rebooting-$FILE
aws s3 cp /home/ec2-user/rebooting-$FILE s3://s3-path/reboot/
 else
rm -f /home/ec2-user/rebooting-$FILE
 fi
/sbin/shutdown -r +$1
 
exit 0

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎