Adapt script whith new conf-sync
This commit is contained in:
parent
bf7d918b76
commit
879fd88945
@ -14,4 +14,4 @@ Files in this repository only cover the SBC setup.
|
||||
* `setup.sh` is a script automating the installation and configuration of required software
|
||||
|
||||
### TODO
|
||||
* When new conf-sync will be available, adapt script
|
||||
* RAS
|
||||
|
7
restart-upmpdcli.service
Normal file
7
restart-upmpdcli.service
Normal file
@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=Restart upmpdcli service
|
||||
Requisite=upmpdcli.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/systemctl restart upmpdcli.service
|
9
restart-upmpdcli.timer
Normal file
9
restart-upmpdcli.timer
Normal file
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Run restart-upmpdcli regularly
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* 08:00:00
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
83
setup.sh
83
setup.sh
@ -35,24 +35,20 @@ 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_conf() {
|
||||
echo "Getting configuration"
|
||||
get_sync() {
|
||||
echo "Getting and deploying sync 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"
|
||||
ln -s $sync_directory_path/*.service $systemd_units_path/
|
||||
ln -s $sync_directory_path/conf-sync-server.timer $systemd_units_path/conf-sync.timer
|
||||
ln -s $sync_directory_path/restart-upmpdcli.timer $systemd_units_path/
|
||||
systemctl daemon-reload
|
||||
systemctl enable conf-sync.timer mpd.service upmpdcli.service restart-upmpdcli.timer
|
||||
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() {
|
||||
@ -63,29 +59,20 @@ set_upmpdcli_service() {
|
||||
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
|
||||
}
|
||||
|
||||
set_cpufreq() { # This is specifically for our Orange Pi Zero; may not be required in all cases
|
||||
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
|
||||
sudo -H -u $user ln -s $sync_directory_path/tmux.conf /home/$user/.tmux.conf
|
||||
ln -s /home/$user/.tmux.conf /root/.tmux.conf
|
||||
}
|
||||
|
||||
ssh_pubkey() {
|
||||
echo "Getting SSH public key"
|
||||
sudo -H -u $user mkdir /home/$user/.ssh
|
||||
@ -93,6 +80,19 @@ ssh_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
|
||||
}
|
||||
|
||||
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!"
|
||||
@ -105,7 +105,7 @@ run_directory_path=$(pwd)
|
||||
# Set parameters
|
||||
default_hostname='orangepizero'
|
||||
hostname='pi2'
|
||||
fqdn='pi2.kto.black'
|
||||
fqdn='pi2.jab.kto.black'
|
||||
keymap='fr'
|
||||
timezone='Europe/Paris'
|
||||
deb_apt_default_repo='deb.debian.org'
|
||||
@ -123,28 +123,25 @@ remote_pubkey='home.pub'
|
||||
init
|
||||
install_packages
|
||||
add_users
|
||||
get_conf
|
||||
set_conf
|
||||
get_sync
|
||||
set_upmpdcli_service
|
||||
set_upmpdcli-restart_service
|
||||
set_alsa_conf
|
||||
set_cpufreq
|
||||
rcs_links
|
||||
ssh_pubkey
|
||||
set_sshd_conf
|
||||
set_cpufreq
|
||||
|
||||
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 a new password for $user"
|
||||
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 "* 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.sh"
|
||||
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