Rename functions to script-functions for easier deploy
This commit is contained in:
20
script-functions
Normal file
20
script-functions
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# Common functions for the lab scripts
|
||||
# Copyright 2021 Bryan C. Roessler
|
||||
|
||||
# Don't run this script directly
|
||||
[[ "${BASH_SOURCE[0]}" == "${0}" ]] && exit 0
|
||||
|
||||
prompt() { read -pr "Enter $1: " "$1"; }
|
||||
|
||||
ask_ok() {
|
||||
declare response
|
||||
(( YES_SWITCH )) && return 0
|
||||
read -r -p "$* [y/N]: " response
|
||||
[[ ${response,,} =~ ^(yes|y)$ ]]
|
||||
}
|
||||
|
||||
is_root() {
|
||||
user=$(whoami)
|
||||
[[ $user != "root" ]] && echo "Script must be run with sudo" && exit 1
|
||||
}
|
||||
Reference in New Issue
Block a user