diff --git a/README.md b/README.md index 04a8cb4..ea58727 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,8 @@ This repository contains files used to setup our SBCs with a freshly installed A Files in this repository only cover the SBC setup. #### Installation * `setup.sh` is a script automating the installation and configuration of required software +* `variables.conf.template` contains examples variables definitions, and should be copied locally to `variables.conf` + (with any required modifications). ### TODO -* not working as of now -* set up variables -* add use cases - * SSH bouncer - * Printscan - * UPNP renderer - * NAS server +* RAS diff --git a/setup.sh b/setup.sh index 210d3d4..4377019 100644 --- a/setup.sh +++ b/setup.sh @@ -3,7 +3,14 @@ # (Keep in mind that default root password is 1234) # Flash SBC's SD with Armbian and clone this repository in /root -# YOU SHOULD REMOVE THIS SCRIPT AFTER SETUP +run_directory=$(dirname $(readlink -f "$0")) +source "$run_directory/variables.conf" + +# Only run if the user is root +if [[ $USER != 'root' ]]; then + echo "You must run this script as root!" + exit 1 +fi # initialization echo "Starting initialization" @@ -14,11 +21,19 @@ 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 +#sed -i -e "s/$deb_apt_default_repo/$deb_apt_repo/g" /etc/apt/sources.list apt update apt upgrade -y -# TODO define $additional-packages, depending on $use-case and $sbc -apt install -y vim tree tmux neofetch git +additional_packages='' +if [[ $use_case = 'printscan-server' ]]; then + additional_packages+="sane sane-utils hplip apache2" +elif [[ $use_case = 'upnp-renderer' ]]; then + 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 + additional_packages+="mpd upmpdcli" +fi +apt install -y vim tree tmux neofetch git $additional_packages # add users echo "Adding users" @@ -38,6 +53,11 @@ sudo -H -u $user cp $sync_directory_path/conf-sync/variables.conf.template \ 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 use case config +echo "Getting and deploying use-case $use_case configuration" +sudo -H -u $user git clone https://gitea.kto.black/adminconf/$use_case.git $sync_directory_path/$use_case +# TODO how to start install? We need to define variables + # SSH config echo "Getting SSH public key" sudo -H -u $user mkdir /home/$user/.ssh @@ -48,31 +68,11 @@ sed -i -e "s/#PasswordAuthentication yes/PasswordAuthentication no/g" /etc/ssh/s sed -i -e "s/PermitRootLogin yes/PermitRootLogin no/g" /etc/ssh/sshd_config # specific function for orangepizero -if [[ $default_hostname = 'orangepizero' ]]; then +if [[ $sbc = '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 -fi - -run_directory_path=$(pwd) - -# Set parameters TODO replace by a variables.conf -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' -remote_pubkey_location='https://keys.kto.black' -remote_pubkey='home.pub' - echo "" echo "We're all good here!" echo "You should now:" diff --git a/variables.conf.template b/variables.conf.template new file mode 100644 index 0000000..006ae0c --- /dev/null +++ b/variables.conf.template @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Copy this file as variables.conf, with the correct values + +fqdn='' +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" +remote_pubkey_location='https://keys.kto.black' +remote_pubkey='home.pub' + +# Choose one of the following use cases: +#use_case='upnp-renderer' +#use_case='ssh-bounce-server' +#use-case='printscan-server' +#use-case='nas-server' + +# Choose one of the following SBC: +#sbc='pine64' +#sbc='orangepizero' +#sbc='odroidhc2'