gonzopi

git clone https://git.tarina.org/gonzopi
Log | Files | Refs | README | LICENSE

install.sh (12350B)


      1 #!/bin/bash
      2 #sed -i '/FILESYSTEMS=/c\FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus ntfs fuseblk vfat"' /etc/usbmount/usbmount.conf
      3 
      4 ROOT_UID=0   # Root has $UID 0.
      5 
      6 update=$1
      7 
      8 if [ "$UID" -eq "$ROOT_UID" ]
      9 then
     10    echo "OK"
     11 else
     12     echo "Run with sudo!"
     13     echo "sudo ./install.sh"
     14     exit 0
     15 fi
     16 
     17 echo "Hurray, you are root! Let's do this.."
     18 cat <<'EOF'
     19  ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄    ▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄ 
     20 █       █       █  █  █ █       █       █       █   █
     21 █   ▄▄▄▄█   ▄   █   █▄█ █▄▄▄▄   █   ▄   █    ▄  █   █
     22 █  █  ▄▄█  █ █  █       █▄▄▄▄█  █  █ █  █   █▄█ █   █
     23 █  █ █  █  █▄█  █  ▄    █ ▄▄▄▄▄▄█  █▄█  █    ▄▄▄█   █
     24 █  █▄▄█ █       █ █ █   █ █▄▄▄▄▄█       █   █   █   █
     25 █▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄█  █▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄▄█   █▄▄▄█
     26 EOF
     27 sleep 1
     28 
     29 if grep -q -F '#gonzopi-rpi-configuration-1.0' /boot/config.txt
     30 then
     31 echo "screen drivers found! remove them in /boot/config.txt"
     32 else
     33 echo "Select screen driver to be installed"
     34 select screen in hyperpixel4 ugeek-hdtft hdmi-screen
     35 do
     36 echo $screen
     37 break
     38 done
     39 fi
     40 echo "setting up system for filmmaking flow..."
     41 echo "if something goes wrong please submit bug to https://github.com/rbckman/gonzopi"
     42 sleep 2
     43 version="$(lsb_release -c -s)"
     44 if [ "$version" = "buster" ]
     45 then
     46     echo "Debian Buster found"
     47 else
     48     echo "Debian Stretch found"
     49 fi
     50 echo "Installing all dependencies..."
     51 
     52 apt-get update
     53 apt-get upgrade -y
     54 if [ "$version" = "buster" ]
     55 then
     56     apt-get -y install git python3-pip python-configparser ffmpeg mediainfo gpac omxplayer sox cpufrequtils apache2 libapache2-mod-wsgi-py3 libdbus-glib-1-dev dbus libdbus-1-dev usbmount python3-numpy python3-pil python3-smbus python3-shortuuid wiringpi make gcc cmake pmount python3-ifaddr python3-pygame
     57 else
     58     apt-get -y install git python3-pip python-configparser libav-tools mediainfo gpac omxplayer sox cpufrequtils apache2 libapache2-mod-wsgi-py3 libdbus-glib-1-dev dbus libdbus-1-dev usbmount python3-numpy python3-pil python3-smbus python3-shortuuid wiringpi make gcc cmake python3-ifaddr python3-pygame
     59 fi
     60 echo "installing python-omxplayer-wrapper..."
     61 pip3 install omxplayer-wrapper
     62 echo "installing blessed..."
     63 pip3 install blessed
     64 echo "installing secrets..."
     65 pip3 install secrets
     66 pip3 install numpy
     67 pip3 install RPi.GPIO
     68 echo "installing picamerax with lens shading correction..."
     69 #sudo pip3 --no-cache-dir install https://github.com/chrisruk/picamera/archive/hq-camera-new-framerates.zip --upgrade
     70 pip3 install --upgrade picamerax
     71 echo "installing web.py for the gonzopi webserver..."
     72 pip3 install web.py==0.61
     73 
     74 if [ "$screen" = "ugeek-hdtft" ]
     75 then
     76 echo "installing ugeek screen drivers"
     77 echo "Gonzopi configuration seems to be in order in /boot/config.txt"
     78 echo "Adding to /boot/config.txt"
     79 cat <<'EOF' >> /boot/config.txt
     80 #-----GonzoPi configuration starts here-------
     81 #gonzopi-rpi-configuration-ugeek-1.0
     82 #Rpi-hd-tft
     83 dtoverlay=dpi18
     84 overscan_left=0
     85 overscan_right=0
     86 overscan_top=0
     87 overscan_bottom=0
     88 framebuffer_width=800
     89 framebuffer_height=480
     90 enable_dpi_lcd=1
     91 display_default_lcd=1
     92 dpi_group=2
     93 dpi_mode=87
     94 dpi_output_format=0x6f015
     95 hdmi_timings=480 0 16 16 24 800 0 4 2 2 0 0 0 60 0 32000000 6
     96 dtoverlay=pi3-disable-bt-overlay
     97 dtoverlay=i2c-gpio,i2c_gpio_scl=24,i2c_gpio_sda=23framebuffer_height=480
     98 display_rotate=3 
     99 start_x=1
    100 gpu_mem=256
    101 disable_splash=1
    102 force_turbo=1
    103 boot_delay=1
    104 dtparam=i2c_arm=on
    105 # dtparam=sd_overclock=90
    106 # Disable the ACT LED.
    107 dtparam=act_led_trigger=none
    108 dtparam=act_led_activelow=off
    109 # Disable the PWR LED.
    110 dtparam=pwr_led_trigger=none
    111 dtparam=pwr_led_activelow=off
    112 
    113 #--------GonzoPi configuration end here---------
    114 EOF
    115 elif [ "$screen" = "hyperpixel4" ]
    116 then
    117 apt-get -y install curl
    118 echo "installing hyperpixel4 screen drivers"
    119 curl -sSL get.pimoroni.com/hyperpixel4-legacy | bash
    120 cat <<'EOF' >> /etc/udev/rules.d/98-hyperpixel4-calibration.rules
    121 ATTRS{name}=="Goodix Capacitive TouchScreen", ENV{LIBINPUT_CALIBRATION_MATRIX}="0 1 0 -1 0 1"
    122 EOF
    123 echo "GonzoPi configuration seems to be in order in /boot/config.txt"
    124 echo "Adding to /boot/config.txt"
    125 cat <<'EOF' >> /boot/config.txt
    126 #-----GonzoPi configuration starts here-------
    127 #gonzopi-rpi-configuration-hyperpixel-1.0
    128 #hyperpixel
    129 #uncomment for pi4
    130 #display_lcd_rotate=1
    131 start_x=1
    132 gpu_mem=128
    133 disable_splash=1
    134 force_turbo=1
    135 boot_delay=1
    136 # dtparam=sd_overclock=90
    137 # Disable the ACT LED.
    138 dtparam=act_led_trigger=none
    139 dtparam=act_led_activelow=off
    140 # Disable the PWR LED.
    141 dtparam=pwr_led_trigger=none
    142 dtparam=pwr_led_activelow=off
    143 framebuffer_width=800
    144 framebuffer_height=480
    145 #hdmi_force_hotplug=1
    146 hdmi_group=1
    147 hdmi_mode=3
    148 [EDID=N/A-]  ##Hyperpixel HD CONFIG
    149 
    150 dtoverlay=hyperpixel4
    151 overscan_left=0
    152 overscan_right=0
    153 overscan_top=0
    154 overscan_bottom=0
    155 enable_dpi_lcd=1
    156 display_default_lcd=1
    157 display_rotate=1
    158 dpi_group=2
    159 hdmi_group=3
    160 dpi_mode=87
    161 dpi_output_format=0x7f216
    162 hdmi_timings=480 0 10 16 59 800 0 15 113 15 0 0 0 60 0 32000000 6
    163 
    164 #--------GonzoPi configuration end here---------
    165 EOF
    166 elif [ "$screen" = "hdmi-screen" ]
    167 then
    168 echo "configuring hdmi screen"
    169 echo "GonzoPi configuration seems to be in order in /boot/config.txt"
    170 echo "Adding to /boot/config.txt"
    171 cat <<'EOF' >> /boot/config.txt
    172 #-----GonzoPi configuration starts here-------
    173 #gonzopi-rpi-configuration-hdmi-screen
    174 start_x=1
    175 gpu_mem=256
    176 disable_splash=1
    177 force_turbo=1
    178 boot_delay=1
    179 # dtparam=sd_overclock=90
    180 # Disable the ACT LED.
    181 dtparam=act_led_trigger=none
    182 dtparam=act_led_activelow=off
    183 # Disable the PWR LED.
    184 dtparam=pwr_led_trigger=none
    185 dtparam=pwr_led_activelow=off
    186 framebuffer_width=800
    187 framebuffer_height=480
    188 #hdmi_force_hotplug=1
    189 hdmi_group=1
    190 hdmi_mode=3
    191 #--------GonzoPi configuration end here---------
    192 EOF
    193 else
    194 echo "screen driver already there, to change it remove gonzopi config in /boot/config.txt"
    195 fi
    196 
    197 echo "Change hostname to gonzopi"
    198 cat <<'EOF' > /etc/hostname
    199 gonzopi
    200 EOF
    201 
    202 cat <<'EOF' > /etc/hosts
    203 127.0.0.1	localhost
    204 ::1		localhost ip6-localhost ip6-loopback
    205 ff02::1		ip6-allnodes
    206 ff02::2		ip6-allrouters
    207 
    208 127.0.1.1	gonzopi
    209 EOF
    210 
    211 echo "consoleblank=0 logo.nologo loglevel=0"
    212 echo "may be put at the end of line in this file /boot/cmdline.txt"
    213 sleep 4
    214 
    215 echo "Make USB soundcard default"
    216 echo "writing to /etc/modprobe.d/alsa-base.conf"
    217 if [ "$version" = "buster" ]
    218 then
    219 echo "Debian Buster Alsa config"
    220 cat <<'EOF' > /etc/modprobe.d/alsa-base.conf
    221 #set index value
    222 options snd-usb-audio index=0
    223 options snd_bcm2835 index=1
    224 #reorder
    225 options snd slots=snd_usb_audio, snd_bcm2835
    226 EOF
    227 else
    228 echo "Debian Stretch Alsa config"
    229 cat <<'EOF' > /etc/modprobe.d/alsa-base.conf
    230 #set index value
    231 options snd_usb_audio index=0
    232 options snd_bcm2835 index=1
    233 #reorder
    234 options snd slots=snd_usb_audio, snd_bcm2835
    235 EOF
    236 fi
    237 
    238 echo "Automatically boot to GonzoPi"
    239 echo "creating a gonzopi.service file"
    240 cat <<'EOF' > /etc/systemd/system/gonzopi.service
    241 [Unit]
    242 Description=gonzopi
    243 After=getty.target
    244 Conflicts=getty@tty1.service
    245 DefaultDependencies=false
    246 
    247 [Service]
    248 Type=simple
    249 RemainAfterExit=yes
    250 ExecStart=/usr/bin/python3 /home/pi/gonzopi/gonzopi.py default
    251 User=pi
    252 Restart=on-failure
    253 StandardInput=tty-force
    254 StandardOutput=inherit
    255 StandardError=inherit
    256 TTYPath=/dev/tty1
    257 TTYReset=yes
    258 TTYVHangup=yes
    259 Nice=-20
    260 CPUSchedulingPolicy=rr
    261 CPUSchedulingPriority=99
    262 
    263 [Install]
    264 WantedBy=local-fs.target
    265 EOF
    266 
    267 #dont kill process if user log out or in
    268 
    269 cat <<'EOF' >> /etc/systemd/logind.conf
    270 KillUserProcesses=no
    271 EOF
    272 
    273 
    274 #thanx systemd for making me search for years to make this all workd like a normal programd.
    275 loginctl enable-linger
    276 loginctl enable-linger pi
    277 
    278 chmod +x /home/pi/gonzopi/gonzopi.py
    279 systemctl enable gonzopi.service
    280 systemctl daemon-reload
    281 echo "systemd configuration done!"
    282 
    283 echo "Installing gonzopi apache server configuration"
    284 cp extras/gonzopi.conf /etc/apache2/sites-available/
    285 #ln -s -t /var/www/ /home/pi/gonzopi/srv/
    286 a2dissite 000-default.conf
    287 a2ensite gonzopi.conf
    288 echo "configure srv path to /home/pi/gonzopi/srv"
    289 
    290 cat <<'EOF' >> /etc/apache2/apache2.conf
    291 <Directory /home/pi/gonzopi/srv>
    292 	Options Indexes FollowSymLinks
    293 	AllowOverride None
    294 	Require all granted
    295 </Directory>
    296 EOF
    297 cat <<'EOF' >> /dev/shm/apache2.conf
    298 <Directory /dev/shm/srv>
    299 	Options Indexes FollowSymLinks
    300 	AllowOverride None
    301 	Require all granted
    302 </Directory>
    303 EOF
    304 systemctl reload apache2
    305 
    306 echo 'Dont do sync while copying to usb drives, does increase speed alöt!'
    307 sed -i '/MOUNTOPTIONS=/c\MOUNTOPTIONS="noexec,nodev,noatime,nodiratime"' /etc/usbmount/usbmount.conf
    308 
    309 echo "Adding harddrive tools..."
    310 cat <<'EOF'
    311 All this hard work to figure out how to keep NTFS mounted was done by F. Untermoser
    312 https://raspberrypi.stackexchange.com/questions/41959/automount-various-usb-stick-file-systems-on-jessie-lite
    313 Thanks alot!
    314 
    315 while we are at it :)
    316 To all the amazing FOSS people out there big big props and
    317   _____  ______  _____ _____  ______ _____ _______ _ 
    318  |  __ \|  ____|/ ____|  __ \|  ____/ ____|__   __| |
    319  | |__) | |__  | (___ | |__) | |__ | |       | |  | |
    320  |  _  /|  __|  \___ \|  ___/|  __|| |       | |  | |
    321  | | \ \| |____ ____) | |    | |___| |____   | |  |_|
    322  |_|  \_\______|_____/|_|    |______\_____|  |_|  (_)
    323 
    324 EOF
    325 apt-get -y install ntfs-3g exfat-fuse
    326 #sed -i -e 's/MountFlags=slave/MountFlags=shared/g' /lib/systemd/system/systemd-udevd.service
    327 #sed -i '/FS_MOUNTOPTIONS=/c\FS_MOUNTOPTIONS="-fstype=ntfs-3g,nls=utf8,umask=007,gid=46 -fstype=fuseblk,nls=utf8,umask=007,gid=46 -fstype=vfat,gid=1000,uid=1000,umask=007"' /etc/usbmount/usbmount.conf
    328 #sed -i '/FILESYSTEMS=/c\FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus ntfs fuseblk vfat"' /etc/usbmount/usbmount.conf
    329 
    330 cat <<'EOF' >> /etc/usbmount/usbmount.conf
    331 FS_MOUNTOPTIONS="-fstype=ntfs-3g,nls=utf8,umask=007,gid=46 -fstype=fuseblk,nls=utf8,umask=007,gid=46 -fstype=vfat,gid=1000,uid=1000,umask=007"
    332 FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus ntfs fuseblk vfat"
    333 EOF
    334 
    335 cat <<'EOF' > /etc/udev/rules.d/usbmount.rules
    336 KERNEL=="sd*", DRIVERS=="sbp2",         ACTION=="add",  PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c"
    337 KERNEL=="sd*", SUBSYSTEMS=="usb",       ACTION=="add",  PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c"
    338 KERNEL=="ub*", SUBSYSTEMS=="usb",       ACTION=="add",  PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c"
    339 KERNEL=="sd*",                          ACTION=="remove",       RUN+="/usr/share/usbmount/usbmount remove"
    340 KERNEL=="ub*",                          ACTION=="remove",       RUN+="/usr/share/usbmount/usbmount remove"
    341 EOF
    342 
    343 cat <<'EOF' > /etc/systemd/system/usbmount@.service
    344 [Unit]
    345 BindTo=%i.device
    346 After=%i.device
    347 
    348 [Service]
    349 Type=oneshot
    350 TimeoutStartSec=0
    351 Environment=DEVNAME=%I
    352 ExecStart=/usr/share/usbmount/usbmount add
    353 RemainAfterExit=yes
    354 EOF
    355 
    356 echo "Adding hacking tools..."
    357 apt-get -y install vim htop screen nmap
    358 cp extras/.vimrc /root/.vimrc
    359 cp extras/.vimrc /home/pi/.vimrc
    360 
    361 echo "Installing youtube upload mod..."
    362 pip3 install pyshorteners
    363 pip3 install google-api-python-client==1.7.3 oauth2client==4.1.2 progressbar2==3.38.0 httplib2==0.15.0
    364 
    365 cd mods
    366 ./install-youtube-upload.sh
    367 cd ..
    368 
    369 echo "Setting up network configuration to use wicd program..."
    370 echo "it works nicer from the terminal than raspberry pi default"
    371 apt-get -y purge dhcpcd5 plymouth
    372 apt-get -y install wicd wicd-curses
    373 
    374 echo "Removing unnecessary programs from startup..."
    375 systemctl disable lightdm.service --force
    376 systemctl disable graphical.target --force
    377 systemctl disable plymouth.service --force
    378 systemctl disable bluetooth.service 
    379 systemctl disable hciuart.service 
    380 
    381 echo "Configure wifi region settings to FI, finland"
    382 echo "You can change settings in extras/wifiset.sh file"
    383 cp extras/wifiset.service /etc/systemd/system/
    384 systemctl daemon-reload
    385 systemctl enable wifiset.service
    386 
    387 echo "HURRAY! WE ARE"
    388 cat <<'EOF'
    389   _____   ____  _   _ ______ _ 
    390  |  __ \ / __ \| \ | |  ____| |
    391  | |  | | |  | |  \| | |__  | |
    392  | |  | | |  | | . ` |  __| | |
    393  | |__| | |__| | |\  | |____|_|
    394  |_____/ \____/|_| \_|______(_)
    395                                
    396 EOF
    397 sleep 2
    398 echo "Rebooting into up-to-date GonzoPi..."
    399 sleep 2
    400 reboot