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

34 lines
779 B
Bash
Raw Permalink Normal View History

2023-04-13 14:04:29 -05:00
#!/usr/bin/env -S sh -i
2023-04-13 14:04:29 -05:00
pacman -Sy --noconfirm --needed git fish sudo
echo "## Arch Linux Provisioning ##"
2023-04-16 02:26:30 -05:00
# TODO: use custom meta packages?
is_root="$(test "$(whoami)" == 'root' && echo "1" || echo "0")"
for file in "$(dirname "$0")/provision.d"/*; do
test -d "$file" && continue
2023-04-13 14:04:29 -05:00
if echo "$file" | grep -q "AS_ROOT"; then
2022-07-19 10:01:14 -05:00
if [ "$is_root" = "1" ]; then
2023-04-13 14:04:29 -05:00
echo "arch/provision.sh: Runnning $file..."
"$file"
else
2023-04-13 14:04:29 -05:00
echo "arch/provision.sh: Runnning sudo $file..."
sudo "$file"
fi
else
2022-07-19 10:01:14 -05:00
if [ "$is_root" = "1" ]; then
2023-04-13 14:04:29 -05:00
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
2023-04-13 14:04:29 -05:00
echo "arch/provision.sh: Runnning $file..."
"$file"
fi
fi
done