Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
roktas committed Oct 16, 2023
1 parent 4dfcb02 commit 4df03ef
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
42 changes: 31 additions & 11 deletions bigbang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ else
fi

LOGFILE="${TMPDIR:-/tmp}"/"${0##*/}"-"$(date --iso-8601=seconds)".log
BRANCH=${1:-}

cd "$WORKDIR"

exec > >(tee "$LOGFILE") 2>&1

cry "... Preparing provisioning"

adduser "$SUDO_USER" sudo

export DEBIAN_FRONTEND=noninteractive && apt-get -y update && apt-get -y install --no-install-recommends \
curl \
git \
Expand All @@ -47,8 +50,10 @@ export DEBIAN_FRONTEND=noninteractive && apt-get -y update && apt-get -y install
zstd \
#

if [[ -z ${TEST:-} ]]; then
git clone --filter=blob:none https://github.com/roktas/dotfiles ${1+--branch="$1"} && cd dotfiles
if [[ -d /vagrant/scripts ]]; then
cd /vagrant
else
git clone --filter=blob:none https://github.com/roktas/dotfiles ${BRANCH:+--branch="$BRANCH"} && cd dotfiles
fi

cry ".. Provisioning system"
Expand Down Expand Up @@ -129,17 +134,32 @@ leave

cry "... Installing dotfiles"

sudo -u "$SUDO_USER" bash install.sh
if [[ -f /vagrant/install.sh ]]; then
sudo -u "$SUDO_USER" bash -s <<'EOF'
cd /vagrant
bash install.sh
EOF
else
sudo -u "$SUDO_USER" bash -s -- "$BRANCH" <<'EOF'
xdg_data_home="${XDG_DATA_HOME:-$HOME/.local/share}"
mkdir -p "$xdg_data_home" && cd "$xdg_data_home"
git clone --filter=blob:none https://github.com/roktas/dotfiles ${1:+--branch="$1"} && cd dotfiles
bash install.sh
EOF
fi
exec &>"$(tty)"
if [[ -z ${TEST-:} ]] && gui; then
notice "Starting Dropbox; please click the login when asked..."
# Finish installations here if not on a physical machine.
if [[ -f /.dockerenv ]] || systemd-detect-virt -q; then
exit 0
fi
sudo -u "$SUDO_USER" bash -s <<-EOF
echo y | dropbox start -i
dropbox autostart y
EOF
notice "Starting Dropbox; please click the login when asked..."
notice "After sync completed, proceed with Dropbox installation: bash dropbox/install.sh"
fi
sudo -u "$SUDO_USER" bash -s <<-EOF
echo y | dropbox start -i
dropbox autostart y
EOF

notice "After sync completed, proceed with Dropbox installation: bash dropbox/install.sh"
4 changes: 2 additions & 2 deletions scripts/terminal/sudo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ set -euo pipefail; [[ -z ${TRACE:-} ]] || set -x

user=$(sudo -u '#1000' sh -c 'echo $USER')

if [[ -n $user ]]; then
if [[ -n $user ]] && [[ $user != vagrant ]]; then
file=/etc/sudoers.d/$user

install -d /etc/sudoers.d && cat >"$file" <<-EOF
$user ALL=(ALL) NOPASSWD: /usr/bin/apt, /usr/bin/apt-get, /usr/bin/dpkg, /usr/sbin/poweroff, /usr/sbin/reboot
EOF

chmod 644 "$file"
chmod 0440 "$file"
fi

0 comments on commit 4df03ef

Please sign in to comment.