diff --git a/ubuntu-initial.sh b/ubuntu-initial.sh index 871a3c4..92f3cd6 100755 --- a/ubuntu-initial.sh +++ b/ubuntu-initial.sh @@ -1,7 +1,12 @@ #!/usr/bin/env bash set -e fail () { echo $1 >&2; exit 1; } -[[ $(id -u) = 0 ]] || [[ -z $SUDO_USER ]] || fail "Please run 'sudo $0'" +if [[ $(id -u) -ne 0 ]] || [[ -z $SUDO_USER ]]; then + fail "Please run 'sudo $0'" +fi +if [[ $(grep -i Microsoft /proc/version) ]]; then + fail "Running on WSL, try running 'sudo ./ubuntu-wsl.sh'" +fi [[ -z $NEWHOST ]] && read -e -p "Enter hostname to set: " NEWHOST [[ $NEWHOST = *.*.* ]] || fail "hostname must contain two '.'s" diff --git a/ubuntu-wsl.sh b/ubuntu-wsl.sh index 26e04bd..a8467f4 100755 --- a/ubuntu-wsl.sh +++ b/ubuntu-wsl.sh @@ -1,7 +1,12 @@ #!/usr/bin/env bash set -e fail () { echo $1 >&2; exit 1; } -[[ $(id -u) = 0 ]] || [[ -z $SUDO_USER ]] || fail "Please run 'sudo $0'" +if [[ $(id -u) -ne 0 ]] || [[ -z $SUDO_USER ]]; then + fail "Please run 'sudo $0'" +fi +if ! [[ $(grep -i Microsoft /proc/version) ]]; then + fail "NOT running on WSL, try running 'sudo ./ubuntu-initial.sh'" +fi echo 'Defaults timestamp_timeout=3600' >> /etc/sudoers