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