News for hackers. Stuff that matters.
Re:Knightmare: A DevOps Cautionary Tale (2014) by phaemon on Wednesday February 04, 2015 @01:35PM (#8998678)
As 'euid' said, you can just add a check. If you don't want to add proper option checking (because this is the only option) you can do something like:

    response=$1

    echo "This will STOP THE SERVER. Are you sure you want to do this?"
    echo "Type 'yes' to continue:"
    [[ $response ]] || read response

    if [[ $response != "yes" ]]
    then
      echo "You must type 'yes' to continue. Aborting."
      exit 1
    fi

    echo "Stopping server ..."
Which will allow you to run the script with "./scriptname.sh yes" to bypass the check.

EDIT: Though, as you say, it is much better not to be running anything like this on a live server anyway. Any change should be part of a deployment procedure that is carefully checked and tested, as well as having a rollback procedure in the event of something horrible happening.

Of course, in the real world, you sometimes don't have that luxury and you just have to hope and pray :-)

There are no comments on this comment yet.