CryptoJones

reboot.sh

Mar 2nd, 2022 (edited)
1,030
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.53 KB | None | 0 0
  1. #!/bin/bash
  2. HOST=`echo $HOSTNAME | sed -e 's/\(.*\)/\L\1/'`
  3. CURRENTDATE=`date +"%Y-%m-%d %T" | sed 's/[[:space:]]//g' | sed 's/:/-/g'`
  4. FILE="$HOST-$CURRENTDATE"
  5. touch /home/ec2-user/rebooting-$FILE
  6. aws s3 cp /home/ec2-user/rebooting-$FILE s3://s3-path/reboot/
  7. FILEEXIST=$(aws s3 ls s3://s3-path/reboot/rebooting-$FILE)
  8.  if [ -z "$FILEEXIST" ]; then
  9. touch /home/ec2-user/rebooting-$FILE
  10. aws s3 cp /home/ec2-user/rebooting-$FILE s3://s3-path/reboot/
  11.  else
  12. rm -f /home/ec2-user/rebooting-$FILE
  13.  fi
  14. /sbin/shutdown -r +$1
  15.  
  16. exit 0
Add Comment
Please, Sign In to add comment