Starting from scratch.....

This is a rebuild of the old GJukebox, but with YII2 on a Beaglebone Black
Post Reply
kylesands
Site Admin
Posts: 6
Joined: Fri Dec 08, 2023 6:00 pm

Starting from scratch.....

Post by kylesands »

general setup

WiFi setup

Code: Select all

iwctl device list
iwctl station wlan0 scan
iwctl station wlan0 get-networks
iwctl --passphrase "[password]" station wlan0 connect "[network name]"
iwctl station wlan0 show
iwctl station wlan0 get-networks
setup.sh

Code: Select all

#!/bin/bash

#Add user to system
if [ $(id -u) -eq 0 ]; then
        echo "Adding user to system:"
        read -p "  Enter username : " username
        read -s -p "  Enter password : " password
        egrep "^$username" /etc/passwd >/dev/null
        if [ $? -eq 0 ]; then
                printf "\n$username already exists!... moving on..."
                echo ""
        else
                pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
                useradd -s /bin/bash -k /etc/skel -m -p "$pass" "$username"
                [ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"

                # Add user to Sudoers list...
                echo "$username         ALL=(ALL:ALL) ALL" >> /etc/sudoers
                echo "www-data ALL = (root) NOPASSWD: /usr/local/jukebox/darkice_start.sh" >> /etc/sudoers
		echo "www-data ALL = (root) NOPASSWD: /usr/local/jukebox/darkice_stop.sh" >> /etc/sudoers
                echo "$username added to /etc/sudoers"
        fi
else
        echo "Only root may add a user to the system."
        exit 2
fi

printf "\n\n"
timedatectl set-timezone 'America/Chicago'
echo "Timezone set to Central"

printf "\n\n"
truncate -s 0 /etc/issue.net
echo "Cleared /etc/issue.net"

printf "\n\n"
echo "Applying updates."
apt -y update && apt -y upgrade
echo "Updates applied."

printf "\n\n"
echo "installing locate and updating its info."
apt-get -y install locate
updatedb
echo "locate installed and updated"

printf "\n\n"
echo "installing Icecast2"
apt-get -y install icecast2
apt-get -y install darkice
apt-get -y install python3-mutagen
modprobe snd-aloop
echo "Icecast2 installed."

printf "\n\n"
apt install apache2
echo "Apache2 installed"

#printf "\n\n"
#echo "Installing firewall and configuring."
#apt -y install ufw
ufw allow 80
ufw allow 8000
ufw allow 1339
ufw allow 22/tcp
#ufw allow 67/udp
#ufw allow 53/udp
#ufw allow 53/tcp
ufw enable
#echo "Firewall installed."

printf "\n\n"
echo "Format MicroSD card."
mke2fs -t ext4 -O ^has_journal /dev/mmcblk0
echo "MicroSD card formatted."


printf "\n\n"
echo "Setting up directory structure."
mkdir /media/Data
mkdir /media/Data/local
#mkdir /media/Data/local/1wire
#mkdir /media/Data/local/scripts
mkdir /media/Data/sdCard

printf "\n\n"
echo "Mounting MicroSD card"
sudo su -c "echo '/dev/mmcblk0 /media/Data/sdCard auto exec,rw,user,auto,nofail 0 0' >> /etc/fstab"
systemctl daemon-reload
mount -a

printf "\n\n"
echo "Add audio group to root for now"
usermod -a -G audio root

printf "\n\n"
echo "Installing MySQL"
apt-get -y install default-mysql-server
mysql_secure_installation
echo "MySQL installed."

printf "\n\n"
echo "Relocating MySQL"
systemctl stop mysql
mkdir /media/Data/sdCard/mysql
sed -i 's_.*\bdatadir\b.*_datadir                 = /media/Data/sdCard/mysql _' /etc/mysql/mariadb.conf.d/50-server.cnf
mv /var/lib/mysql/* /media/Data/sdCard/mysql/
chown -R mysql:mysql /media/Data/sdCard/mysql
echo "MySQL relocated"

printf "\n\n"
echo "Make new MySQL service."
touch /lib/systemd/system/my_mysql.service
echo "[Unit]" >> /lib/systemd/system/my_mysql.service
echo "Description=use systemctl to start mySQL" >> /lib/systemd/system/my_mysql.service
echo "After=multi-user.target" >> /lib/systemd/system/my_mysql.service
echo "" >> /lib/systemd/system/my_mysql.service
echo "[Service]" >> /lib/systemd/system/my_mysql.service
echo "Type=forking" >> /lib/systemd/system/my_mysql.service
echo "ExecStart=systemctl start mysql" >> /lib/systemd/system/my_mysql.service
echo "" >> /lib/systemd/system/my_mysql.service
echo "[Install]" >> /lib/systemd/system/my_mysql.service
echo "WantedBy=multi-user.target" >> /lib/systemd/system/my_mysql.service
echo "" >> /lib/systemd/system/my_mysql.service
systemctl daemon-reload
systemctl enable my_mysql.service
systemctl start my_mysql
echo "New MySQL service made."

#printf "\n\n"
#echo "Remove nginx"
#systemctl stop nginx
#systemctl disable nginx
#apt-get -y purge nginx nginx-common
#echo "Nginx removed"

#printf "\n\n"
#echo "Growing MicroSD card partition size."
#/opt/scripts/tools/grow_partition.sh
#echo "MicroSD card partition size grew."

printf "\n\n"
echo "Install PHP"
apt-get install php8.2 php8.2-cli php8.2-cgi php8.2-fpm php8.2-gd php8.2-mysql php8.2-imap php8.2-curl php8.2-intl php8.2-pspell php8.2-sqlite3 php8.2-tidy php8.2-xsl php8.2-zip php8.2-mbstring php8.2-soap php8.2-opcache libonig5 php8.2-common php8.2-readline php8.2-xml

Post Reply