21 lines
399 B
Bash
21 lines
399 B
Bash
#!/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
|
|
|
|
|
|
ask_ok() {
|
|
read -r -p "$* [y/N]: " response
|
|
response=${response,,}
|
|
[[ "$response" =~ ^(yes|y)$ ]]
|
|
}
|
|
|
|
|
|
is_root() {
|
|
user=$(whoami)
|
|
[[ $user != "root" ]] && echo "Script must be run with sudo" && exit 1
|
|
}
|
|
|