gonzopi

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

install.sh (12786B)


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