tarina

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

install.sh (11095B)


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