gonzopi

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

install.sh (12233B)


      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 sudo pip3 install omxplayer-wrapper
     62 echo "installing blessed..."
     63 sudo pip3 install blessed
     64 echo "installing secrets..."
     65 sudo pip3 install secrets
     66 sudo pip3 install numpy
     67 sudo 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 sudo pip3 install --upgrade picamerax
     71 echo "installing web.py for the gonzopi webserver..."
     72 sudo 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 systemctl reload apache2
    298 
    299 echo 'Dont do sync while copying to usb drives, does increase speed alöt!'
    300 sed -i '/MOUNTOPTIONS=/c\MOUNTOPTIONS="noexec,nodev,noatime,nodiratime"' /etc/usbmount/usbmount.conf
    301 
    302 echo "Adding harddrive tools..."
    303 cat <<'EOF'
    304 All this hard work to figure out how to keep NTFS mounted was done by F. Untermoser
    305 https://raspberrypi.stackexchange.com/questions/41959/automount-various-usb-stick-file-systems-on-jessie-lite
    306 Thanks alot!
    307 
    308 while we are at it :)
    309 To all the amazing FOSS people out there big big props and
    310   _____  ______  _____ _____  ______ _____ _______ _ 
    311  |  __ \|  ____|/ ____|  __ \|  ____/ ____|__   __| |
    312  | |__) | |__  | (___ | |__) | |__ | |       | |  | |
    313  |  _  /|  __|  \___ \|  ___/|  __|| |       | |  | |
    314  | | \ \| |____ ____) | |    | |___| |____   | |  |_|
    315  |_|  \_\______|_____/|_|    |______\_____|  |_|  (_)
    316 
    317 EOF
    318 apt-get -y install ntfs-3g exfat-fuse
    319 #sed -i -e 's/MountFlags=slave/MountFlags=shared/g' /lib/systemd/system/systemd-udevd.service
    320 #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
    321 #sed -i '/FILESYSTEMS=/c\FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus ntfs fuseblk vfat"' /etc/usbmount/usbmount.conf
    322 
    323 cat <<'EOF' >> /etc/usbmount/usbmount.conf
    324 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"
    325 FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus ntfs fuseblk vfat"
    326 EOF
    327 
    328 cat <<'EOF' > /etc/udev/rules.d/usbmount.rules
    329 KERNEL=="sd*", DRIVERS=="sbp2",         ACTION=="add",  PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c"
    330 KERNEL=="sd*", SUBSYSTEMS=="usb",       ACTION=="add",  PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c"
    331 KERNEL=="ub*", SUBSYSTEMS=="usb",       ACTION=="add",  PROGRAM="/bin/systemd-escape -p --template=usbmount@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c"
    332 KERNEL=="sd*",                          ACTION=="remove",       RUN+="/usr/share/usbmount/usbmount remove"
    333 KERNEL=="ub*",                          ACTION=="remove",       RUN+="/usr/share/usbmount/usbmount remove"
    334 EOF
    335 
    336 cat <<'EOF' > /etc/systemd/system/usbmount@.service
    337 [Unit]
    338 BindTo=%i.device
    339 After=%i.device
    340 
    341 [Service]
    342 Type=oneshot
    343 TimeoutStartSec=0
    344 Environment=DEVNAME=%I
    345 ExecStart=/usr/share/usbmount/usbmount add
    346 RemainAfterExit=yes
    347 EOF
    348 
    349 echo "Adding hacking tools..."
    350 apt-get -y install vim htop screen nmap
    351 cp extras/.vimrc /root/.vimrc
    352 cp extras/.vimrc /home/pi/.vimrc
    353 
    354 echo "Installing youtube upload mod..."
    355 pip3 install pyshorteners
    356 pip3 install google-api-python-client==1.7.3 oauth2client==4.1.2 progressbar2==3.38.0 httplib2==0.15.0
    357 
    358 cd mods
    359 ./install-youtube-upload.sh
    360 cd ..
    361 
    362 echo "Setting up network configuration to use wicd program..."
    363 echo "it works nicer from the terminal than raspberry pi default"
    364 apt-get -y purge dhcpcd5 plymouth
    365 apt-get -y install wicd wicd-curses
    366 
    367 echo "Removing unnecessary programs from startup..."
    368 systemctl disable lightdm.service --force
    369 systemctl disable graphical.target --force
    370 systemctl disable plymouth.service --force
    371 systemctl disable bluetooth.service 
    372 systemctl disable hciuart.service 
    373 
    374 echo "Configure wifi region settings to FI, finland"
    375 echo "You can change settings in extras/wifiset.sh file"
    376 cp extras/wifiset.service /etc/systemd/system/
    377 systemctl daemon-reload
    378 systemctl enable wifiset.service
    379 
    380 echo "HURRAY! WE ARE"
    381 cat <<'EOF'
    382   _____   ____  _   _ ______ _ 
    383  |  __ \ / __ \| \ | |  ____| |
    384  | |  | | |  | |  \| | |__  | |
    385  | |  | | |  | | . ` |  __| | |
    386  | |__| | |__| | |\  | |____|_|
    387  |_____/ \____/|_| \_|______(_)
    388                                
    389 EOF
    390 sleep 2
    391 echo "Rebooting into up-to-date GonzoPi..."
    392 sleep 2
    393 reboot