mostly fixes for new error handling
[distro-setup] / disabled / kodi-setup
1 #!/bin/bash
2
3 # this is from distro-end
4 if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
5
6 pi kodi
7
8 # based on https://wiki.debian.org/SecuringNFS
9 # but the quota stuff is either outdated or optional,
10 # i guessed that it was not needed and it worked fine.
11 s dd of=/etc/sysctl.d/nfs-static-ports.conf <<'EOF'
12 fs.nfs.nfs_callback_tcpport = 32764
13 fs.nfs.nlm_tcpport = 32768
14 fs.nfs.nlm_udpport = 32768
15 EOF
16 s sysctl --system
17 s $sed -ri -f - /etc/default/nfs-common <<'EOF'
18 /^\s*STATDOPTS=/d
19 $a STATDOPTS="--port 32765 --outgoing-port 32766"
20 EOF
21
22 s $sed -ri -f - /etc/default/nfs-kernel-server <<'EOF'
23 /^\s*RPCMOUNTDOPTS=/d
24 $a RPCMOUNTDOPTS="--manage-gids --port 32767"
25 EOF
26 ser restart nfs-kernel-server
27
28 if [[ $HOSTNAME == kd ]]; then
29 # persistent one time steps for webdav:
30 # create persistent password, put it in ~/.kodi/userdata/advancedsettings.xml,
31 # per http://kodi.wiki/view/MySQL/Sync_other_parts_of_Kodi
32 # htpasswd -c /p/c/filesystem/etc/davpass dav
33 # chmod 640 /p/c/filesystem/etc/davpass
34 # in conflink, set group to www-data.
35 # In kodi, i set the music source, server address: my domain,
36 # path: k/music. Then copied the file
37 # /p/c/subdir_files/.kodi/userdata/sources.xml to save that setting.
38 s a2enmod dav dav_fs
39 web-conf -r /a/c/playlists - apache2 dav.$HOME_DOMAIN <<'EOF'
40 <Directory /a/c/playlists>
41 DAV On
42 AuthType Basic
43 AuthName "Authentication Required"
44 AuthUserFile "/etc/davpass"
45 Require valid-user
46
47 # outside the standard /var/www, so use this:
48 Order allow,deny
49 Allow from all
50 </Directory>
51 EOF
52 s mkdir -p /var/www/davlock
53 s chown www-data:www-data /var/www/davlock
54 s sed -i "1i DavLockDB /var/www/davlock/davlock" /etc/apache2/sites-enabled/dav.$HOME_DOMAIN.conf
55 ser reload apache2
56
57 teeu /etc/exports "/k/music *(ro,nohide,async,no_subtree_check,insecure)"
58 exportfs -ra
59
60 # kodi uses sqlite by default, but supports mysql.
61 pi mariadb-server
62
63 # see ofswiki.org for explanation.
64 dbpass="$(cat /p/mysql-root-pass)"
65 if ! echo exit|mysql -uroot "-p$dbpass"; then
66 echo -e "\n\n$dbpass\n$dbpass\n\n\n\n\n" | mysql_secure_installation
67 fi
68 mysql -uroot "-p$dbpass" <<EOF
69 GRANT ALL PRIVILEGES ON *.* TO 'kodi' IDENTIFIED BY '$(</p/mysql-kodi-pass)';
70 EOF
71 s sed -ri 's/^(\s*bind-address\s*=).*/\1 0.0.0.0/' /etc/mysql/mariadb.conf.d/50-server.cnf
72 ser restart mariadb
73
74 fi