gonzopi

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

install.sh (12977B)


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