.
This commit is contained in:
parent
656c6431a5
commit
844ab60834
@ -1,6 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
# bootstrapping with sh until we have bash installed
|
||||
# can you make this script run in bash, but fall back to sh if bash is not installed?
|
||||
|
||||
# check if we are running as root
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
@ -15,8 +13,11 @@ if ! command -v bash > /dev/null 2>&1; then
|
||||
apt install -y bash
|
||||
fi
|
||||
|
||||
# switch to bash as our shell
|
||||
chsh -s /bin/bash
|
||||
# re-exec this script in bash if not already running in bash
|
||||
if [ -z "$BASH_VERSION" ]; then
|
||||
echo "Re-executing script in Bash..."
|
||||
exec /bin/bash "$0" "$@"
|
||||
fi
|
||||
|
||||
if [ -n "$BASH_VERSION" ]; then
|
||||
echo "Running in Bash $BASH_VERSION"
|
||||
@ -84,6 +85,9 @@ if [ ! -f "/home/dropshell/.ssh/known_hosts" ]; then
|
||||
touch /home/dropshell/.ssh/known_hosts
|
||||
fi
|
||||
|
||||
# ensure default shell for dropshell user is bash
|
||||
chsh -s /bin/bash dropshell
|
||||
|
||||
#--------------------------------
|
||||
|
||||
# download dropshell
|
||||
|
@ -6,46 +6,6 @@
|
||||
# It is called with the path to the server specific env file as an argument.
|
||||
|
||||
|
||||
attempt_install_prerequisite() {
|
||||
local prerequisite="${1}"
|
||||
echo "Attempting to install prerequisite: ${prerequisite}"
|
||||
|
||||
# test if root, and test sudo otherwise.
|
||||
SUDO_CMD=""
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
if ! sudo -v; then
|
||||
echo "--------------------------------"
|
||||
echo "Prerequisite: ${prerequisite} is not installed."
|
||||
echo "Please run the script with sudo privileges or as root to automatically install the prerequisite."
|
||||
echo "--------------------------------"
|
||||
exit 1
|
||||
fi
|
||||
SUDO_CMD="sudo "
|
||||
fi
|
||||
|
||||
|
||||
# separate install for each prerequisite
|
||||
case "${prerequisite}" in
|
||||
bash|curl|wget)
|
||||
$SUDO_CMD apt-get update
|
||||
$SUDO_CMD apt-get install -y wget curl bash
|
||||
;;
|
||||
"docker")
|
||||
# install docker using the official script.
|
||||
curl -fsSL https://get.docker.com -o get-docker.sh
|
||||
$SUDO_CMD sh get-docker.sh
|
||||
rm get-docker.sh
|
||||
;;
|
||||
*)
|
||||
echo "--------------------------------"
|
||||
echo "Prerequisite: ${prerequisite} is not installed."
|
||||
echo "Please install it manually and try again."
|
||||
echo "--------------------------------"
|
||||
exit 1
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
install_prerequisites() {
|
||||
# this script works on debian, ubuntu and Raspberry Pi OS
|
||||
# it checks the following prerequisites, and installs them if missing.
|
||||
@ -63,7 +23,7 @@ install_prerequisites() {
|
||||
# check if all prerequisites are installed
|
||||
for prerequisite in "${PREREQUISITES[@]}"; do
|
||||
if ! command -v "${prerequisite}" &> /dev/null; then
|
||||
attempt_install_prerequisite "${prerequisite}"
|
||||
echo "Prerequisite: ${prerequisite} is not installed."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
Loading…
x
Reference in New Issue
Block a user