gonzopi

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

install.sh (12405B)


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