Upgrade to version 2.1: System setup is done by armbian-setup
This commit is contained in:
parent
51033160c3
commit
18f4540e9c
10
README.md
10
README.md
@ -1,7 +1,7 @@
|
||||
# uPnP renderer
|
||||
## Version 2
|
||||
## Version 2.1
|
||||
|
||||
This repository contains files used to set up our uPnP renderer on a freshly installed Armbian. Target is Bullseye.
|
||||
This repository contains files used to set up our uPnP renderer.
|
||||
|
||||
### Introduction
|
||||
Version 2 implementation works roughly as follows:
|
||||
@ -9,9 +9,11 @@ Version 2 implementation works roughly as follows:
|
||||
* MPD and upmpdcli are installed on the device.
|
||||
|
||||
### Files
|
||||
Files in this repository only cover the SBC setup.
|
||||
Files in this repository only cover the renderer setup. SBC setup is now handled by `armbian-setup`
|
||||
#### Installation
|
||||
* `setup.sh` is a script automating the installation and configuration of required software
|
||||
* `asound.conf` is the default ALSA configuration
|
||||
* `restart.upmpdcli.service`, `restart.upmpdcli.timer` and `exec.conf` are the Systemd service configuration
|
||||
|
||||
### TODO
|
||||
* REVIEW THE SCRIPT TO ONLY SET UP RENDERER, INSTALLATION IS DONE BY armbian-setup
|
||||
* RAS
|
||||
|
2
asound.conf
Normal file
2
asound.conf
Normal file
@ -0,0 +1,2 @@
|
||||
defaults.pcm.card 0
|
||||
defaults.ctl.card 0
|
3
exec.conf
Normal file
3
exec.conf
Normal file
@ -0,0 +1,3 @@
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/usr/bin/upmpdcli -f %H
|
156
setup.sh
156
setup.sh
@ -1,149 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# The purpose of this script is to setup our UPnP AV/DLNA renderer on a blank Armbian.
|
||||
# This script is to be run as root.
|
||||
run_directory=$(dirname $(readlink -f "$0"))
|
||||
user=$(whoami)
|
||||
|
||||
# (Keep in mind that default root password is 1234)
|
||||
# Flash SBC's SD with Armbian and copy this script as well as conf-sync.sh to /root
|
||||
|
||||
# YOU SHOULD REMOVE THIS SCRIPT AFTER SETUP
|
||||
|
||||
# Functions
|
||||
init() {
|
||||
echo "Starting initialization"
|
||||
echo $fqdn > /etc/hostname
|
||||
sed -i -e "s/=default_hostname/$fqdn $hostname/g" /etc/hosts
|
||||
localectl set-keymap $keymap
|
||||
timedatectl set-timezone $timezone
|
||||
systemctl disable apt-daily-upgrade.timer
|
||||
}
|
||||
|
||||
install_packages() {
|
||||
echo "Starting packages installation"
|
||||
sed -i -e "s/$deb_apt_default_repo/$deb_apt_repo/g" /etc/apt/sources.list
|
||||
|
||||
wget -P /usr/share/keyrings/ https://www.lesbonscomptes.com/pages/lesbonscomptes.gpg
|
||||
wget -P /etc/apt/sources.list.d/ https://www.lesbonscomptes.com/upmpdcli/pages/upmpdcli-rbullseye.list
|
||||
sed -i -e "s/deb-src/#deb-src/g" /etc/apt/sources.list.d/upmpdcli-rbullseye.list
|
||||
|
||||
apt update
|
||||
apt upgrade -y
|
||||
apt install -y vim tree tmux neofetch mpd upmpdcli
|
||||
}
|
||||
|
||||
add_users() {
|
||||
echo "Adding users"
|
||||
useradd -U -G sudo -m -s /bin/bash $user
|
||||
chmod 700 /home/$user
|
||||
echo "Let's define a password for $user as we are about to run sudo with it. It can of course be changed after setup."
|
||||
passwd $user
|
||||
}
|
||||
|
||||
get_sync() {
|
||||
echo "Getting and deploying sync configuration"
|
||||
sudo -H -u $user mkdir $sync_directory_path
|
||||
sudo -H -u $user git clone https://gitea.kto.black/adminconf/rcs-general.git $sync_directory_path/rcs-general
|
||||
sudo -H -u $user $sync_directory_path/rcs-general/install.sh
|
||||
sudo -H -u $user git clone https://gitea.kto.black/adminconf/conf-sync.git $sync_directory_path/conf-sync
|
||||
sudo -H -u $user cp $sync_directory_path/conf-sync/variables.conf.template \
|
||||
$sync_directory_path/conf-sync/variables.conf
|
||||
sudo -H -u $user sed -i -e "s/\"desktop\"/\"server\"/g" $sync_directory_path/conf-sync/variables.conf
|
||||
sudo -H -u $user $sync_directory_path/conf-sync/install.sh
|
||||
}
|
||||
|
||||
set_upmpdcli_service() {
|
||||
echo "Setting custom upmpdcli service unit"
|
||||
mkdir $systemd_units_path/upmpdcli.service.d
|
||||
echo "[Service]" > $systemd_units_path/upmpdcli.service.d/exec.conf
|
||||
echo "ExecStart=" >> $systemd_units_path/upmpdcli.service.d/exec.conf
|
||||
echo "ExecStart=/usr/bin/upmpdcli -f %H" >> $systemd_units_path/upmpdcli.service.d/exec.conf
|
||||
}
|
||||
|
||||
set_upmpdcli-restart_service() {
|
||||
echo "Setting custom upmpdcli-restart service unit"
|
||||
cp $run_directory_path/restart-upmpdcli.service $systemd_units_path/
|
||||
cp $run_directory_path/restart-upmpdcli.timer $systemd_units_path/
|
||||
systemctl daemon-reload
|
||||
systemctl enable restart-upmpdcli.timer
|
||||
}
|
||||
|
||||
set_alsa_conf() {
|
||||
echo "Setting ALSA configuration"
|
||||
echo "defaults.pcm.card $audio_device" > $alsa_conf_file_path
|
||||
echo "defaults.ctl.card $audio_device" >> $alsa_conf_file_path
|
||||
}
|
||||
|
||||
ssh_pubkey() {
|
||||
echo "Getting SSH public key"
|
||||
sudo -H -u $user mkdir /home/$user/.ssh
|
||||
sudo -H -u $user wget -P /home/$user/.ssh $remote_pubkey_location/$remote_pubkey
|
||||
sudo -H -u $user mv /home/$user/.ssh/$remote_pubkey /home/$user/.ssh/authorized_keys
|
||||
}
|
||||
|
||||
set_sshd_conf() {
|
||||
echo "Editing OpenSSH daemon config..."
|
||||
sed -i -e "s/#PasswordAuthentication yes/PasswordAuthentication no/g" /etc/ssh/sshd_config
|
||||
sed -i -e "s/PermitRootLogin yes/PermitRootLogin no/g" /etc/ssh/sshd_config
|
||||
}
|
||||
|
||||
# TODO in new massive revamp of Armbian setup scripts (in one new big script), this will become a by-SBC function, and
|
||||
# we should add the following for opizero: rm /etc/NetworkManager/conf.d/10-override-wifi-random-mac-disable.conf
|
||||
set_cpufreq() {
|
||||
if [ $default_hostname = 'orangepizero' ]; then
|
||||
echo "Setting CPU frequency to performance"
|
||||
sed -i -e "s/GOVERNOR=ondemand/GOVERNOR=performance/g" /etc/default/cpufrequtils
|
||||
fi
|
||||
}
|
||||
|
||||
# Only run if the user is root
|
||||
if [[ $USER != 'root' ]] ; then
|
||||
echo "You must run this script as root!"
|
||||
exit 1
|
||||
if [[ $user != 'root' ]]; then
|
||||
sudo="sudo"
|
||||
else
|
||||
sudo=""
|
||||
fi
|
||||
|
||||
echo "You are about to deploy uPnP renderer."
|
||||
run_directory_path=$(pwd)
|
||||
echo "Setting custom upmpdcli service unit"
|
||||
$sudo mkdir /etc/systemd/system/upmpdcli.service.d
|
||||
$sudo cp $run_directory/exec.conf /etc/systemd/system/upmpdcli.service.d/exec.conf
|
||||
|
||||
# Set parameters
|
||||
default_hostname='orangepizero'
|
||||
hostname='pi2'
|
||||
fqdn='pi2.jab.kto.black'
|
||||
keymap='fr'
|
||||
timezone='Europe/Paris'
|
||||
deb_apt_default_repo='deb.debian.org'
|
||||
deb_apt_repo='ftp.fr.debian.org'
|
||||
user='alex'
|
||||
sync_directory_path="/home/$user/.sync"
|
||||
systemd_units_path='/etc/systemd/system'
|
||||
audio_device='0'
|
||||
alsa_conf_file_path='/etc/asound.conf'
|
||||
remote_pubkey_location='https://keys.kto.black'
|
||||
remote_pubkey='home.pub'
|
||||
echo "Setting custom upmpdcli-restart service unit"
|
||||
$sudo cp $run_directory/restart-upmpdcli.service /etc/systemd/system/
|
||||
$sudo cp $run_directory/restart-upmpdcli.timer /etc/systemd/system/
|
||||
$sudo systemctl daemon-reload
|
||||
$sudo systemctl enable restart-upmpdcli.timer
|
||||
|
||||
# Main process
|
||||
# You should comment below what you do not want to happen
|
||||
init
|
||||
install_packages
|
||||
add_users
|
||||
get_sync
|
||||
set_upmpdcli_service
|
||||
set_upmpdcli-restart_service
|
||||
set_alsa_conf
|
||||
ssh_pubkey
|
||||
set_sshd_conf
|
||||
set_cpufreq
|
||||
echo "Setting ALSA configuration"
|
||||
$sudo cp $run_directory/asound.conf /etc/asound.conf
|
||||
|
||||
echo ""
|
||||
echo "We're all good here!"
|
||||
echo "You should now:"
|
||||
echo "* lock root account"
|
||||
echo "* reboot the SBC"
|
||||
echo "And perhaps:"
|
||||
echo "* set a new password for $user"
|
||||
echo "* set htop at your convenience"
|
||||
echo "* remove password for sudo" # TODO we should automate that, with a flag
|
||||
echo "* set up Wi-Fi connection"
|
||||
echo " * and then you may want to check on $sync_directory_path/auto-disable-wifi"
|
||||
echo "Please also note that default audio device has been set to $audio_device"
|
||||
echo "If you wish to change this, you may edit /etc/asound.conf"
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user