Skip to content

Commit

Permalink
Fixed sudo check, added WSL check
Browse files Browse the repository at this point in the history
  • Loading branch information
stillgreyfox committed Oct 21, 2022
1 parent b9ed10f commit ea6fa1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ubuntu-initial.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
7 changes: 6 additions & 1 deletion ubuntu-wsl.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit ea6fa1b

Please sign in to comment.