This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/os/linux/arch/provision.sh

32 lines
744 B
Bash
Executable file

#!/usr/bin/env -S sh -i
pacman -Sy --noconfirm --needed git fish sudo
echo "## Arch Linux Provisioning ##"
is_root="$(test "$(whoami)" == 'root' && echo "1" || echo "0")"
for file in "$(dirname "$0")/provision.d"/*; do
test -d "$file" && continue
if echo "$file" | grep -q "AS_ROOT"; then
if [ "$is_root" = "1" ]; then
echo "arch/provision.sh: Runnning $file..."
"$file"
else
echo "arch/provision.sh: Runnning sudo $file..."
sudo "$file"
fi
else
if [ "$is_root" = "1" ]; then
nf="$(mktemp)"
cp "$file" "$nf"
chmod 777 "$nf"
echo "arch/provision.sh: Runnning sudo -u daniel $file via $nf..."
sudo -u daniel "$nf"
rm "$nf"
else
echo "arch/provision.sh: Runnning $file..."
"$file"
fi
fi
done