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