Initial commit - version 1
This commit is contained in:
commit
c8b657d4d1
14
README.md
Normal file
14
README.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# uPnP renderer
|
||||||
|
## Version 1
|
||||||
|
|
||||||
|
This repository contains files used to set up our uPnP renderer on a freshly installed Armbian. Target is Buster.
|
||||||
|
|
||||||
|
### Introduction
|
||||||
|
Version 1 implementation works roughly as follows:
|
||||||
|
* the Armbian-based device is connected to local network, and to an audio output device (usually via USB);
|
||||||
|
* MPD and upmpdcli are installed on the device.
|
||||||
|
|
||||||
|
### Files
|
||||||
|
Files in this repository only cover the SBC setup.
|
||||||
|
#### Installation
|
||||||
|
* `setup.sh` is a script automating the installation and configuration of required software
|
159
setup.sh
Normal file
159
setup.sh
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
#!/bin/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.
|
||||||
|
|
||||||
|
# (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"
|
||||||
|
curl https://www.lesbonscomptes.com/pages/jf-at-dockes.org.pgp | gpg --import -
|
||||||
|
gpg --export '7808CE96D38B9201' | apt-key add -
|
||||||
|
sed -i -e "s/$deb_apt_default_repo/$deb_apt_repo/g" /etc/apt/sources.list
|
||||||
|
echo "deb http://www.lesbonscomptes.com/upmpdcli/downloads/raspbian/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/upmpdcli.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
|
||||||
|
}
|
||||||
|
|
||||||
|
set_sudo_conf() { # TODO that doesn't seem to work
|
||||||
|
echo "Setting sudo configuration"
|
||||||
|
sed -i -e "s/%sudo ALL=(ALL:ALL) ALL/%sudo ALL=(ALL:ALL) $sudo_no_passwd ALL/g" /etc/sudoers
|
||||||
|
}
|
||||||
|
|
||||||
|
get_conf() {
|
||||||
|
echo "Getting configuration"
|
||||||
|
sudo -H -u $user mkdir $sync_directory_path
|
||||||
|
cp $run_directory_path/conf-sync.sh $sync_directory_path/
|
||||||
|
chown $user:$user $sync_directory_path/conf-sync.sh
|
||||||
|
sudo -H -u $user chmod u+x $sync_directory_path/conf-sync.sh
|
||||||
|
sudo -H -u $user $sync_directory_path/conf-sync.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
set_conf() {
|
||||||
|
echo "Setting configuration"
|
||||||
|
#sudo -H -u $user chmod uo+x $sync_directory_path/clean-cloud.sh $sync_directory_path/scan-to-cloud.sh
|
||||||
|
ln -s $sync_directory_path/*.service $systemd_units_path/
|
||||||
|
ln -s $sync_directory_path/*.timer $systemd_units_path/
|
||||||
|
#ln -s $sync_directory_path/*.socket $systemd_units_path/ # TODO add a check here
|
||||||
|
#ln -s $sync_directory_path/*.mount $systemd_units_path/
|
||||||
|
#ln -s $sync_directory_path/*.path $systemd_units_path/
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable conf-sync.timer mpd.service upmpdcli.service restart-upmpdcli.timer
|
||||||
|
}
|
||||||
|
|
||||||
|
set_upmpdcli_service() {
|
||||||
|
echo "Setting custom upmpdcli service unit"
|
||||||
|
# Old way, less clean
|
||||||
|
#cp /lib/systemd/system/upmpdcli.service $systemd_units_path/
|
||||||
|
#sed -i -e "s/upmpdcli -c \/etc\/upmpdcli.conf/upmpdcli -f %H/g" $systemd_units_path/upmpdcli.service
|
||||||
|
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_alsa_conf() {
|
||||||
|
echo "Setting ALSA configuration"
|
||||||
|
echo "defaults.pcm.card $audio_device
|
||||||
|
defaults.ctl.card $audio_device" > $alsa_conf_file_path
|
||||||
|
}
|
||||||
|
|
||||||
|
set_cpufreq() {
|
||||||
|
echo "Setting CPU frequency to performance"
|
||||||
|
sed -i -e "s/GOVERNOR=ondemand/GOVERNOR=performance/g" /etc/default/cpufrequtils
|
||||||
|
}
|
||||||
|
|
||||||
|
rcs_links() {
|
||||||
|
echo "Linking rcs"
|
||||||
|
rm /home/$user/.bashrc
|
||||||
|
rm /root/.bashrc
|
||||||
|
sudo -H -u $user ln -s $sync_directory_path/bashrc /home/$user/.bashrc
|
||||||
|
ln -s /home/$user/.bashrc /root/.bashrc
|
||||||
|
sudo -H -u $user ln -s $sync_directory_path/vimrc /home/$user/.vimrc
|
||||||
|
ln -s /home/$user/.vimrc /root/.vimrc
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
# Only run if the user is root
|
||||||
|
if [[ $USER != 'root' ]] ; then
|
||||||
|
echo "You must run this script as root!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "You are about to deploy printscan server."
|
||||||
|
run_directory_path=$(pwd)
|
||||||
|
|
||||||
|
# Set parameters
|
||||||
|
default_hostname='orangepizero'
|
||||||
|
hostname='pi2'
|
||||||
|
fqdn='pi2.kto.black'
|
||||||
|
keymap='fr'
|
||||||
|
timezone='Europe/Paris'
|
||||||
|
deb_apt_default_repo='httpredir.debian.org'
|
||||||
|
deb_apt_repo='ftp.fr.debian.org'
|
||||||
|
user='alex'
|
||||||
|
sudo_no_passwd="NOPASSWD:"
|
||||||
|
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'
|
||||||
|
|
||||||
|
# Main process
|
||||||
|
# You should comment below what you do not want to happen
|
||||||
|
init
|
||||||
|
install_packages
|
||||||
|
add_users
|
||||||
|
set_sudo_conf
|
||||||
|
get_conf
|
||||||
|
set_conf
|
||||||
|
set_upmpdcli_service
|
||||||
|
set_alsa_conf
|
||||||
|
set_cpufreq
|
||||||
|
rcs_links
|
||||||
|
ssh_pubkey
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "We're all good here!"
|
||||||
|
echo "You should now:"
|
||||||
|
echo "* set $user's password"
|
||||||
|
echo "* lock root account"
|
||||||
|
echo "* remove setup.sh and conf-sync.sh"
|
||||||
|
echo "* reboot the SBC"
|
||||||
|
echo "And perhaps:"
|
||||||
|
echo "* set htop at your convenience"
|
||||||
|
echo "* use below commands to edit SSH config:"
|
||||||
|
echo " sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config"
|
||||||
|
echo " sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config"
|
||||||
|
echo "* set up Wi-Fi connection"
|
||||||
|
echo " * and then you may want to check on $sync_directory_path/auto-disable-wifi.sh"
|
||||||
|
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