############################################################# Quick Commands ############################################################# #Test network speed (2 options) #Get two linux boxes, install iperf iperf [TARGET_IP] #Tune HDD sudo apt-get install hdparm hdparm -I /dev/sda ############################################################# Recipes ############################################################# ################################ # File/DLNA/LAMP server setup # ################################ ###Mount disk on folder #To partition & format new drive: #Find disk (eg. /dev/sda) sudo fdisk -l #Partition disk sudo parted /dev/sda mkpart primary ext4 0% 100% #Format partition sudo mkfs.ext4 /dev/sda1 #Mount disk (test first, then edit fstab) (nofail will allow pi to boot even if disk is missing) sudo mount /dev/sda1 /home/pi/nas0 sudo nano /etc/fstab /dev/sda1 /home/pi/nas0 ext4 defaults,nofail 0 2 #Change ownership, permissions sudo chown pi -R /home/pi/nas0 sudo chmod 777 -R /home/pi/nas0 ###Setup Network nano /etc/network/interfaces source-directory /etc/network/interfaces.d auto lo eth0 iface lo inet loopback allow-hotplug eth0 iface eth0 inet static address 192.168.2.66 netmask 255.255.255.0 gateway 192.168.2.1 nano /etc/dhcpcd.conf as above, nameserver = 192.168.2.1 8.8.8.8 [something in hex] #Change Hostname sudo nano /etc/hostname #Replace with occam sudo nano /etc/hosts # add occam 127.0.0.1 ###Install Samba sudo smbpasswd -a pi //enter password for remote entry sudo chown -R /etc/samba/smb.conf nano /etc/samba/smb.conf #Add the following [NAS0] comment = share-read-write path = /home/pi/nas0 read only = No create mask = 0777 force create mode = 0777 directory mask = 0777 directory mode = 0777 force directory mode = 0777 guest ok = Yes Test param file: testparm ###Install MiniDLNA: apt-get install minidlna nano /etc/minidlna.conf DON'T SET AUDIO FOLDER TO 'A' - This will make it ignore playlists! Rebuild library: sudo service minidlna force-reload https://help.ubuntu.com/community/MiniDLNA ###Install Apache: apt-get install apache2 Restarting: sudo service apache2 restart Content: /var/www/html Set permissions: sudo chmod 777 /var/www/html Settings: /etc/apache2 http://www.zdnet.com/article/raspberry-pi-extending-the-life-of-the-sd-card/ https://www.htpcguides.com/spin-down-and-manage-hard-drive-power-on-raspberry-pi/ ################################ #### Headless DLNA Renderer #### ################################ Headless DLNA Renderer Hardware: Orange Pi Zero w/ 3.5mm jack on pinout https://oshlab.com/orange-pi-zero-pinout/ 2GB MicroSD (uses 1.3GB) OS: Use --> Armbian 5.35 (legacy) Armbian 5.38 Available, but no sound driver installed Instructions: sudo apt-get upgrade https://github.com/hzeller/gmrender-resurrect ALSA cd ./scripts/init.d sudo cp gmediarenderer /etc/init.d/gmediarenderer sudo nano /etc/init.d/gmediarenderer DAEMON_USER="tyler:audio" Add quotations around variables in script Add to Start: --ip-address 192.168.2.x http://blog.scphillips.com/posts/2013/01/making-gmediarender-start-on-boot/ (explicit instructions below) sudo chmod 755 /etc/init.d/gmediarenderer sudo update-rc.d gmediarenderer defaults Check volume 100% amixer set PCM -- -000 2018-03-21 Constantly freezing, last msg on /var/log/syslog is: root command -v debian-sa1 > /dev/null && debian-sa1 1 1 sudo apt-get remove sysstat 2018-05-15 Apt-Get Upgrade 2019-03-05 Installed on RPi 3 A+ with Raspbian Stretch 2018-10-09 Notes: https://github.com/hzeller/gmrender-resurrect/issues/47 https://github.com/hzeller/gmrender-resurrect/issues/47 List sound cards: aplay -l ################################ ############ Volumio ########### ################################ http://www.raspberrypiwiki.com/images/2/23/PiFi_User_Guide.pdf sudo nano /boot/config.txt ADD: dtoverlay=hifiberry-dacplus sudo nano /etc/asound.conf pcm.!default { type hw card 0 } ctl.!default { type hw card 0 } sudo shutdown -r now TEST: aplay -l Should see HifiBerry DAC HiFi pcm5102a-hifi-0[] ################################ ############ Motion ############ ################################ https://www.bouvet.no/bouvet-deler/utbrudd/building-a-motion-activated-security-camera-with-the-raspberry-pi-zero Raspbian Stretch sudo raspi-config login automatically as PI to CLI enable camera apt-get update apt-get dist-upgrade wget github.com/Motion-Project/motion/releases/download/release-4.0.1/pi_stretch_motion_4.0.1-1_armhf.deb sudo apt-get install gdebi-core sudo gdebi pi_stretch_motion_4.0.1-1_armhf.deb sudo nano /etc/motion/motion.conf Uncomment the mmalcam_name vc. ril. camera parameter. Uncomment target_dir and change it's associated value to ’/home/pi/Documents/motion’ Ensure that ffmpeg_output_movies is set to 'off' Set stream_localhost to ‘off’ Set webcontrol_localhost to 'off’ Set width to ‘1920’ and height to ‘1080’ Set locate_motion_mode to ‘preview’ Set locate_motion_style to ‘redbox’ Set event_gap to '10' Set output_pictures to 'center' Set quality to '90' Set text_changes to 'on' motion -c /etc/motion/motion.conf http://192.168.2.52:8081/ sudo chown -0777 /etc/motion sudo chown -0777 /home/pi/Documents/motion sudo apt-get samba sudo nano /etc/samba/smb.conf SHARE THESE DIRECTORIES ############################################ #### Make Power Button Work on Pi 3B/B+ #### ############################################ # Ref: http://www.barryhubbard.com/raspberry-pi/howto-raspberry-pi-raspbian-power-on-off-gpio-button # https://howchoo.com/g/mwnlytk3zmm/how-to-add-a-power-button-to-your-raspberry-pi # Reference for LED Hearbeat on button push: https://www.raspberrypi.org/forums/viewtopic.php?t=12530 #### Install Python and GPIO Packages #### # Ref: https://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberry-pi/install-python-module-rpi-dot-gpio apt install python-dev python3-dev gcc python-pip apt install python-dev python-rpi.gpio #### Create Python Script #### sudo nano /usr/local/bin/listen-for-shudown.py ctl-o clt-x sudo chown -R pi /usr/local/bin/listen-for-shutdown.py sudo nano /usr/local/bin/listen-for-shutdown.py #!/usr/bin/env python import RPi.GPIO as GPIO import subprocess GPIO.setmode(GPIO.BCM) GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.wait_for_edge(3, GPIO.FALLING) trf = open("/sys/class/leds/led0/trigger","w") trf.write("heartbeat") trf.close() subprocess.call(['shutdown', '-h', 'now'], shell=False) EOF chmod +x /usr/local/bin/listen-for-shutdown.py #### Create service script #### sudo nano /etc/init.d/listen-for-shutdown.sh #! /bin/sh ### BEGIN INIT INFO # Provides: listen-for-shutdown.py # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO # If you want a command to always run, put it here # Carry out specific functions when asked to by the system case "$1" in start) echo "Starting listen-for-shutdown.py" /usr/local/bin/listen-for-shutdown.py & ;; stop) echo "Stopping listen-for-shutdown.py" pkill -f /usr/local/bin/listen-for-shutdown.py ;; *) echo "Usage: /etc/init.d/listen-for-shutdown.sh {start|stop}" exit 1 ;; esac exit 0 EOF chmod +x /etc/init.d/listen-for-shutdown.sh #Register the service to run at for boot update-rc.d listen-for-shutdown.sh defaults /etc/init.d/listen-for-shutdown.sh start