2024-07-26 23:19:51 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-07-27 09:27:30 -04:00
|
|
|
# Root check
|
2024-07-26 23:19:51 -04:00
|
|
|
if [ "$UID" != "0" ]; then
|
2024-07-27 16:08:43 -04:00
|
|
|
echo "Error: Please run as root"
|
|
|
|
exit 1
|
2024-07-26 23:19:51 -04:00
|
|
|
fi
|
|
|
|
|
2024-07-27 09:27:30 -04:00
|
|
|
# Setup
|
2024-07-26 23:36:10 -04:00
|
|
|
rw
|
2024-07-27 10:18:39 -04:00
|
|
|
|
2024-07-27 16:08:43 -04:00
|
|
|
# Install git
|
|
|
|
if [ -z "$(which git)" ]; then
|
|
|
|
echo "Installing Git..."
|
|
|
|
pacman -S --noconfirm git
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Pull repo/dependencies & re-run from there
|
2024-07-27 10:18:39 -04:00
|
|
|
git status > /dev/null
|
|
|
|
if [ "$?" != "0" ]; then
|
2024-07-27 16:08:43 -04:00
|
|
|
echo "Missing dependencies, cloning..."
|
|
|
|
git clone https://git.zakscode.com/ztimson/PiKVM.git
|
|
|
|
cd PiKVM
|
|
|
|
./install.sh
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2024-07-27 17:05:48 -04:00
|
|
|
echo "Running updates, this might take a few minutes..."
|
|
|
|
pikvm-update
|
|
|
|
|
2024-07-27 16:08:43 -04:00
|
|
|
# Fix banner
|
|
|
|
echo ""
|
|
|
|
echo "Updating the banner..."
|
|
|
|
cp motd /etc/motd
|
|
|
|
|
|
|
|
# Update Hostname
|
|
|
|
echo ""
|
|
|
|
read -p "Change hostname (Blank to skip): " $H
|
|
|
|
if [ -n "$H" ]; then
|
|
|
|
sed -i "s/$HOSTNAME/$H" /etc/hostname
|
|
|
|
sed -i "s/$HOSTNAME/$H" /etc/hosts
|
2024-07-27 10:18:39 -04:00
|
|
|
fi
|
2024-07-26 23:19:51 -04:00
|
|
|
|
2024-07-27 09:27:30 -04:00
|
|
|
# Static MAC fix
|
2024-07-27 10:18:39 -04:00
|
|
|
echo ""
|
|
|
|
read -p "Enable static MAC (y/n): " YN
|
|
|
|
if [ "${YN,,}" == "y" ]; then
|
2024-07-27 16:08:43 -04:00
|
|
|
printf "Define vendor ID (Default (Intel): 80:86:00): " && read MAC_PREFIX
|
|
|
|
if [ -z "$MAC_PREFIX" ]; then MAC_PREFIX="80:86:00"; fi
|
2024-07-27 09:27:30 -04:00
|
|
|
|
2024-07-27 16:08:43 -04:00
|
|
|
files=(
|
|
|
|
"/etc/systemd/network/eth0.network"
|
|
|
|
"/etc/systemd/network/wlan0.network"
|
|
|
|
)
|
2024-07-27 09:27:30 -04:00
|
|
|
|
2024-07-27 16:08:43 -04:00
|
|
|
for file in "${files[@]}"; do
|
|
|
|
if [ -n "$(cat $file | grep MACAddress )" ]; then continue; fi
|
|
|
|
mac_address=$(printf '%02X:%02X:%02X' $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256)))
|
|
|
|
cat <<EOF >> "$file"
|
2024-07-27 09:27:30 -04:00
|
|
|
|
|
|
|
[Link]
|
2024-07-27 10:18:39 -04:00
|
|
|
MACAddress=$MAC_PREFIX:$mac_address
|
2024-07-27 09:27:30 -04:00
|
|
|
EOF
|
2024-07-27 16:08:43 -04:00
|
|
|
done
|
2024-07-27 09:27:30 -04:00
|
|
|
fi
|
|
|
|
|
2024-07-27 16:08:43 -04:00
|
|
|
# Access point
|
|
|
|
echo ""
|
|
|
|
read -p "Enable access point on network outage (y/n): " YN
|
|
|
|
if [ "${YN,,}" == "y" ]; then
|
|
|
|
pacman -Sy --noconfirm cronie
|
|
|
|
echo ""
|
|
|
|
echo "Access Point: $SSID"
|
|
|
|
while true; do
|
|
|
|
read -p "Password: " PASSWORD
|
|
|
|
if [ ${#PASSWORD} -ge 8 ]; then break; fi
|
|
|
|
echo "Error: Minimum 8 characters"
|
|
|
|
done
|
|
|
|
bin/access-point.sh -f --passwd $PASSWORD
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
read -p "Enable E-Ink display (y/n): " YN
|
|
|
|
if [ "${YN,,}" == "y" ]; then
|
|
|
|
./bin/swap-manager.sh 1024
|
2024-07-27 10:18:39 -04:00
|
|
|
|
2024-07-27 16:08:43 -04:00
|
|
|
pacman -Sy --noconfirm python-pipx
|
|
|
|
pipx install pillow
|
|
|
|
pipx install RPI.GPIO
|
|
|
|
pipx install spidev
|
|
|
|
|
|
|
|
./bin/swap-manager.sh --disable
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "Setup Complete! Please reboot..."
|