Improve the client setup script

This commit is contained in:
Logan Cusano
2024-03-10 03:22:04 -04:00
parent 7983670c81
commit b209a672c6

View File

@@ -56,15 +56,55 @@ prompt_nearby_system() {
}," },"
} }
####------------------- Initial Prereqs and init steps # Install Node Repo
# Get the CPU architecture
cpu_arch=$(uname -m)
# Print the CPU architecture for verification
echo "Detected CPU Architecture: $cpu_arch"
# Check if the architecture is ARMv6
if [[ "$cpu_arch" == "armv6"* ]]; then
echo "----- CPU Architecture is ARMv6 or compatible. -----"
echo "----- CPU Architectre is not compatible with dependencies of this project, please use a newer CPU architecture -----"
exit
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
# Update the system # Update the system
echo "Updating system..." apt update
apt update && apt upgrade -y apt upgrade -y
# Install required dependencies: nodejs, ffmpeg # Install the necessary packages
echo "Installing dependencies..." echo "Installing dependencies..."
apt install -y nodejs ffmpeg git apt install -y nodejs portaudio19-dev libportaudio2 libpulse-dev pulseaudio apulse git ffmpeg git
echo "Setting up Pulse Audio"
# Ensure pulse audio is running as system so the service can see the audio device
systemctl --global disable pulseaudio.service pulseaudio.socket
# Update the PulseAudio config to disable autospawning
sed -i 's/autospawn = .*$/autospawn = no/' /etc/pulse/client.conf
# Add the system PulseAudio service
echo "[Unit]
Description=PulseAudio system server
[Service]
Type=notify
ExecStart=pulseaudio --daemonize=no --system --realtime --log-target=journal
[Install]
WantedBy=multi-user.target" >> /etc/systemd/system/PulseAudio.service
# Add the root user to the pulse-access group
usermod -aG pulse-access root
usermod -aG pulse-access pi
# Enable the PulseAudio service
systemctl enable PulseAudio.service
systemctl stop PulseAudio.service
####------------------- Install and setup node ####------------------- Install and setup node
# Run npm install to install dependencies listed in package.json # Run npm install to install dependencies listed in package.json
@@ -142,6 +182,7 @@ echo "$service_content" > /etc/systemd/system/discord-radio-bot.service
# Reload systemd daemon # Reload systemd daemon
systemctl daemon-reload systemctl daemon-reload
systemctl enable discord-radio-bot.service
systemctl stop discord-radio-bot.service systemctl stop discord-radio-bot.service
echo "\n\n\t\tDiscord Client Node install completed!\n\n" echo "\n\n\t\tDiscord Client Node install completed!\n\n"
@@ -199,4 +240,22 @@ chown -R 1000:1000 ./*
chown 1000:1000 .env chown 1000:1000 .env
echo "Permissions set on the client directory!" echo "Permissions set on the client directory!"
echo "\n\n\t\tNode installation Complete!" echo "\n\n\t\tNode installation Complete!"
# Prompt the user for reboot confirmation
read -p "This script has installed all required components for the DRB client. Are you okay with rebooting? If not, you will have to reboot later before running the applications to finish the installation. (Reboot?: y/n): " confirm
# Convert user input to lowercase for case-insensitive comparison
confirm="${confirm,,}"
#echo "To configure the app, please go to http://$nodeIP:$nodePort" # TODO - uncomment when webapp is built
echo "Thank you for joining the network!"
if [[ "$confirm" != "y" && "$confirm" != "yes" ]]; then
# Prompt user to press any key before rebooting
read -rsp $'System will now reboot, press any key to continue or Ctrl+C to cancel...\n' -n1 key
echo "Rebooting..."
reboot
else
echo "Please restart your device to complete the installation"
fi