Last active
February 26, 2018 20:29
-
-
Save rifatx/40eb67982aaa28df544219a54ebb79c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# enable ssh on initial boot | |
touch ssh | |
# ssh public key setup | |
mkdir -p ./home/pi/.ssh | |
cat << EOF > ./home/pi/.ssh/authorized_keys | |
# --- BEGIN PVE --- | |
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEApHSlBYGanB/nObsWYIZXF7kcT9Sa2oATwdnNqkb+K/8P3MRLY67g1Ki1yhATpqkPhGrwie5wa60+5T2WpVAyeQ4GzxHVZ9Vjk64Wmc/2yabq4LZRnw+9uZvH2Wx5UlMkOJM2trKYZof6pdz/n044BVihZnFQfWnTYg8vKlKKtFsL0sGKz+DWBgr49fldj4qUB6Nmn5M7+4RqYAAd3af+6ljOSCv4NG2r1ZbMRcBW89569/msPcfQYcBzVXXeC5Z+7o5Svk/10pzUaT6P09Kyz8j6T8iy/T+ugsYZ4Se3l2SRtnAFsd2AJMu6kHp5vaqNOZbnJLuAvbQVp+NL/KI88GZbGNZnua1C/L2zLwarpdZw27NgOJRc4U2sNVPI9qWlXNAPPkpVmpbQvX7gem0BmQdoTgYU6nXexTzGDlSX5yCc13i+xeIJKOf0cCLRse3JLD1fxefqlr2HqlH3cx1ISl0T4Pcj+8QuWAVmAASRaR6+ij31nArIAnPmvAGFDvrfa4Tp6AYQNxmjrqyMBrO0r6NpwbHwKzEsYBoAKjuQTBeE5E+mAPpJWOF+tVZlLPuWZyI1IfPIluVgOnSJ/F1iC4MhAFVZ+bUiQl2p2cUEL2Qzajzm9CfAABIDHSj/piqkv2+8xVbkDn0qtM21q1nMbJnxu0gFqUyVZtE1Vz+VXy0= rifat.aricanli@gmail.com | |
# --- END PVE --- | |
EOF | |
# disable pw auth | |
sed -rie "s|^PasswordAuthentication yes$|#PasswordAuthentication no|" ./etc/ssh/sshd_config | |
sed -rie "s|^PasswordAuthentication no$|#PasswordAuthentication no|" ./etc/ssh/sshd_config | |
sed -re "\$aPasswordAuthentication no" | |
sed -re "s|^#PubkeyAuthentication yes$|PubkeyAuthentication yes|" ./etc/ssh/sshd_config | |
# wpa password | |
wpa_passphrase osman ##PASSWORD## >> ./etc/wpa_supplicant/wpa_supplicant.conf | |
# network interface setup - static wlan ip | |
cat << EOF > ./etc/network/interfaces | |
auto wlan0 | |
iface lo inet loopback | |
iface eth0 inet dhcp | |
allow-hotplug wlan0 | |
iface wlan0 inet static | |
address 192.168.0.133 | |
netmask 255.255.255.0 | |
gateway 192.168.0.1 | |
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf | |
iface default inet dhcp | |
EOF | |
# install kodi and xvfb | |
apt update | |
apt install -y xvfb kodi | |
# user setup | |
groupadd kodi | |
useradd kodi -u 420 -g kodi -G audio,video,plugdev,input -d /var/lib/kodi -s /usr/bin/nologin | |
passwd -l kodi > /dev/null | |
mkdir -p /var/lib/kodi/.kodi | |
chown -R kodi:kodi /var/lib/kodi/.kodi | |
# systemd files | |
cat << EOF > /etc/systemd/system/xvfb.service | |
[Unit] | |
Description = Xvfb Daemon | |
# if you don't need the MySQL DB backend, this should be sufficient | |
After = systemd-user-sessions.service network.target sound.target | |
[Service] | |
User = kodi | |
Group = kodi | |
Type = simple | |
ExecStart = /usr/bin/Xvfb -shmem -screen 0 1280x1024x24 :99 | |
Environment = DISPLAY=:99 | |
Restart = always | |
RestartSec = 15 | |
[Install] | |
WantedBy = multi-user.target | |
EOF | |
cat << EOF > /etc/systemd/system/kodi.service | |
[Unit] | |
Description = Kodi Media Center | |
# if you don't need the MySQL DB backend, this should be sufficient | |
After = systemd-user-sessions.service network.target sound.target xvfb.service | |
# if you need the MySQL DB backend, use this block instead of the previous | |
# After = systemd-user-sessions.service network.target sound.target mysql.service | |
# Wants = mysql.service | |
[Service] | |
User = kodi | |
Group = kodi | |
Type = simple | |
ExecStart = /usr/bin/kodi | |
Environment = DISPLAY=:99 | |
Restart = always | |
RestartSec = 15 | |
[Install] | |
WantedBy = multi-user.target | |
EOF | |
# start daemons | |
systemctl daemon-reload | |
systemctl enable xvfb | |
systemctl enable kodi | |
systemctl start xvfb | |
systemctl start kodi | |
# backup an existing kodi home and scp it to raspi | |
rm /home/r/kodi-new.tar.gz | |
tar -zcvf /home/r/kodi-new.tar.gz /home/r/.kodi | |
scp kodi-new.tar.gz pi@192.168.0.133:~/ | |
rm /home/pi/kodi-new.tar.gz | |
rm -rf /var/lib/kodi/.kodi | |
tar -xf /home/pi/kodi-new.tar.gz -C /var/lib/kodi/ | |
chown -R kodi:kodi /var/lib/kodi/.kodi | |
systemctl restart kodi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment