Skip to content

Instantly share code, notes, and snippets.

@nullne
Last active November 1, 2020 03:13
Show Gist options
  • Save nullne/0083cc2f89f0f700223430ba02e7cf07 to your computer and use it in GitHub Desktop.
Save nullne/0083cc2f89f0f700223430ba02e7cf07 to your computer and use it in GitHub Desktop.
build movie server on pi
set -x
# download Raspberry PI imager to burn cd
# openvpn
apt install openvpn -y
cat >> /etc/openvpn/movie.conf << EOF
openvpn config content here
# username on first line, password on second
auth-user-pass /etc/openvpn/client/passwd
EOF
systemctl daemon-reload
systemctl restart openvpn
journalctl -f -u openvpn@movie
# mount
mkdir -p /data/{mars,mercury}
mount -t ext4 /dev/sdb /data/mercury/
mount /dev/sda /data/mars/
# samba
sudo apt update
sudo apt install samba
cat >> /etc/samba/smb.conf << EOF
[Movies]
comment = YY's Media center
path = /data
read only = yes
browsable = yes
guest ok = yes
EOF
service smbd restart
# syncthing
# https://apt.syncthing.net/
# Add the release PGP keys:
curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
# Add the "stable" channel to your APT sources:
echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
# Increase preference of Syncthing's packages ("pinning")
printf "Package: *\nPin: origin apt.syncthing.net\nPin-Priority: 990\n" | sudo tee /etc/apt/preferences.d/syncthing
# Update and install syncthing:
sudo apt-get update
sudo apt-get install syncthing
#sudo apt-get install apt-transport-https
mkdir -p /syncthing
syncthing -home /syncthing
# change listen address on file /syncthing/config.xml
# other configs may be needed according to the GUI
# connect ip if got
# https://docs.syncthing.net/users/autostart.html#how-to-set-up-a-system-service
sudo cat >> /etc/systemd/system/syncthing@.service << EOF
[Unit]
Description=Syncthing - Open Source Continuous File Synchronization for %I
Documentation=man:syncthing(1)
After=network.target
[Service]
User=%i
ExecStart=/usr/bin/syncthing -no-restart -logflags=0 -home=/syncthing
Restart=on-failure
RestartSec=5
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
# Hardening
ProtectSystem=full
PrivateTmp=true
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
EOF
sudo cat >> /etc/systemd/system/syncthing-resume.service << EOF
[Unit]
Description=Restart Syncthing after resume
Documentation=man:syncthing(1)
After=sleep.target
[Service]
Type=oneshot
ExecStart=-/usr/bin/pkill -HUP -x syncthing
[Install]
WantedBy=sleep.target
EOF
systemctl enable syncthing@ubuntu.service
systemctl start syncthing@ubuntu.service
journalctl -f -u syncthing@ubuntu.service
# plex server
sudo apt-get install apt-transport-https
wget https://downloads.plex.tv/plex-media-server-new/1.20.3.3483-211702a9f/debian/plexmediaserver_1.20.3.3483-211702a9f_armhf.deb
sudo dpkg -i plexmediaserver_1.20.3.3483-211702a9f_armhf.deb
sudo systemctl enable plexmediaserver.service
sudo systemctl start plexmediaserver.service
sudo systemctl status plexmediaserver.service
# http://plex_server_IP:32400/web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment