From d1eed4fba7ab05c7cf58a1de4480529324cd5df9 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Fri, 30 Dec 2022 14:32:09 -0500
Subject: linhes-system: adjustments to initial startup

---
 linhes/linhes-system/PKGBUILD           | 12 ++++++---
 linhes/linhes-system/lh_server.cnf      | 47 +++++++++++++++++++++++++++++++++
 linhes/linhes-system/lh_system_start.sh | 22 ++++++++++-----
 3 files changed, 70 insertions(+), 11 deletions(-)
 create mode 100644 linhes/linhes-system/lh_server.cnf

diff --git a/linhes/linhes-system/PKGBUILD b/linhes/linhes-system/PKGBUILD
index e0fdbe5..c754b54 100755
--- a/linhes/linhes-system/PKGBUILD
+++ b/linhes/linhes-system/PKGBUILD
@@ -1,11 +1,11 @@
 pkgname=linhes-system
 pkgver=9.0.0
-pkgrel=16
+pkgrel=18
 arch=('x86_64')
 #install=$pkgname.install
 pkgdesc="Everything that makes LinHES a system"
 license=('GPL2')
-depends=('cronie' 'dbus-python' 'kdialog' 'libnotify' 'linhes-templates' 'pacman-contrib'
+depends=('cronie' 'dbus-python' 'kdialog' 'libnotify' 'linhes-templates' 'linhes-theme' 'pacman-contrib'
          'openssh' 'ttf-overlock')
 binfiles="add_storage.py balance_storage_groups.py empty_storage_groups.py remove_storage.py
           checkXFSfrag.sh enableIRWake.sh idle.py lh_system_start.sh lh_notify-send
@@ -18,7 +18,7 @@ source=($binfiles
     'readme_is_xml' 'add_storage.readme'
     '79-cronie.hook' 'fstrim.hook' 'openssh.hook'
     '10-monitor.conf' 'x11vnc.override.conf'
-    'system-sudo.rules' 'linhes-profile.sh'
+    'system-sudo.rules' 'linhes-profile.sh' 'lh_server.cnf'
     'lh_system_start.sh.desktop')
 sha256sums=('7f91d2afcb76e8e9063c6bbe05f5c3d134a6f67541aead8894d342c32d34ad98'
             'b0e8fe4d04e1f779d52a28156489fb51efc13e173efccba2d6d458044bf35904'
@@ -27,7 +27,7 @@ sha256sums=('7f91d2afcb76e8e9063c6bbe05f5c3d134a6f67541aead8894d342c32d34ad98'
             '11168c9cd3b117decaab6bc665c183b4aab917cf0a976bce4c1b5e4686a27bc9'
             'ae34515e144830f424d3bd3f6b1b446892d62beed20bca6f0fb19b0bbb779f27'
             '23358a7bff4968eccd469613b81b1415c2ae0ebe77f14f74426697333e4d88d7'
-            '6cba5af4e2f0707bc3374d8fc83b489839a880c76ceea5583a030d885e32ebe2'
+            '918dda99d7d4045af4bc7f36d7bcf1af5be8d76af1bc0e1ab990957a8ea3606e'
             '6d4fb0ed1a5ed961b3a3884dce093118e50c2981a9cd5837d20abc5a6d4fd8aa'
             '87875d9e5f5ce18208f419698ce69b6bcbcd08955a57a4a13940e715af58b787'
             '91bdec992bb2c933e15625c181f2195c402060b879168ebf35944cb064c904b9'
@@ -50,6 +50,7 @@ sha256sums=('7f91d2afcb76e8e9063c6bbe05f5c3d134a6f67541aead8894d342c32d34ad98'
             '2c9152ed542bb9c3aa516c6009125a757065100a060e0fa597243d4cbd92844f'
             'a9d0a94ff442453f0bec0b2e8afd591cf17b2845b6ae45ff300530114efd30af'
             '47ace62d7e7e651f25dc7c0a2e96d0862f5efe1a583eeda2843b1fc1499141fe'
+            '4b89eb5aeb6ea8f0be5fd16cae3c2536114dfb0b594c64e9f44e7c2394079e7e'
             '0b9868a563036c81f8fdb8ab8bbad51934aca2a07e9d7634e24214791afda8e2')
 
 package() {
@@ -72,6 +73,9 @@ package() {
     #systemd files
     install -Dm644 $srcdir/x11vnc.override.conf $pkgdir/etc/systemd/system/x11vnc.service.d/override.conf
 
+    #sql files
+    install -Dm644 $srcdir/lh_server.cnf $pkgdir/etc/my.cnf.d/lh_server.cnf
+
     #readme files
     install -Dm644 $srcdir/readme_is_xml $pkgdir/etc/gen_is_xml.d/readme_is_xml
     install -Dm644 $srcdir/readme_is_xml $pkgdir/etc/gen_lib_xml.d/readme_gen_xml
diff --git a/linhes/linhes-system/lh_server.cnf b/linhes/linhes-system/lh_server.cnf
new file mode 100644
index 0000000..1850f8e
--- /dev/null
+++ b/linhes/linhes-system/lh_server.cnf
@@ -0,0 +1,47 @@
+#
+# These groups are read by MariaDB server.
+# Use it for options that only the server (but not clients) should see
+#
+# See the examples of server my.cnf files in /usr/share/mysql/
+#
+
+# this is read by the standalone daemon and embedded servers
+[server]
+
+# this is only for the mysqld standalone daemon
+[mysqld]
+
+#
+# * Galera-related settings
+#
+[galera]
+# Mandatory settings
+#wsrep_on=ON
+#wsrep_provider=
+#wsrep_cluster_address=
+#binlog_format=row
+#default_storage_engine=InnoDB
+#innodb_autoinc_lock_mode=2
+#
+# Allow server to accept connections on all interfaces.
+#
+#bind-address=0.0.0.0
+#
+# Optional setting
+#wsrep_slave_threads=1
+#innodb_flush_log_at_trx_commit=0
+
+# this is only for embedded server
+[embedded]
+
+# This group is only read by MariaDB servers, not by MySQL.
+# If you use the same .cnf file for MySQL and MariaDB,
+# you can put MariaDB-only options here
+[mariadb]
+datadir=/data/srv/mysql
+
+# This group is only read by MariaDB-10.8 servers.
+# If you use the same .cnf file for MariaDB of different versions,
+# use this group for options that older servers don't understand
+[mariadb-10.8]
+
diff --git a/linhes/linhes-system/lh_system_start.sh b/linhes/linhes-system/lh_system_start.sh
index ff5360f..cd7ae8a 100755
--- a/linhes/linhes-system/lh_system_start.sh
+++ b/linhes/linhes-system/lh_system_start.sh
@@ -2,7 +2,8 @@
 
 . /etc/profile
 #. /etc/systemconfig
-#SystemType=Masterbackend
+
+HOSTNAME=`/usr/bin/hostnamectl hostname`
 
 function msg(){
     /usr/bin/lh_notify-send --app-name="LinHES" --icon=dialog-information "$1" "$2"
@@ -63,12 +64,23 @@ function storage_scan(){
 
 function install_lh_apps(){
     #install programs that are not needed on the iso
-    msg "Installing apps..."
+    msg "Installing apps. This could take a few minutes."
     sudo pacman -Syyy --noconfirm firefox glances mythtv mythplugins-mytharchive mythplugins-mythmusic mythplugins-mythweb ncdu x11vnc
     status=$?
     [ $status -eq 1 ] && msg "Could not install apps. Check internet connection." && exit 1
 }
 
+function sql_setup(){
+    sudo mkdir -p /data/srv/mysql
+    sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/data/srv/mysql
+    sudo systemctl enable --now mariadb.service
+    mysql_tzinfo_to_sql /usr/share/zoneinfo | sudo mysql -u root mysql
+    sudo mariadb -u root < /usr/share/linhes/templates/db/permissions.sql
+    mythtv-setup -O theme=LinHES
+    sed -e "s/apheleia/${HOSTNAME}/g" /usr/share/linhes/templates/db/custom.sql > /tmp/custom.sql.fixed
+    sudo mariadb -u root mythconverg < /tmp/custom.sql.fixed
+}
+
 function first_configure(){
     if [ ! -f ~/.config/lh_configured ]; then
         #apply settings for all system types
@@ -87,12 +99,8 @@ function first_configure(){
             sudo mkdir -p /data/storage/disk0
             sudo create_media_dirs.sh /data/storage/disk0
             # setup DB
-            sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
-            sudo systemctl enable --now mariadb.service
-            sudo mariadb -u root < /usr/share/linhes/templates/db/permissions.sql
-            mysql_tzinfo_to_sql /usr/share/zoneinfo | sudo mysql -u root mysql
+            sql_setup
             # run mythtv-setup
-            mythtv-setup
             # need to run twice for default db install/upgrade
             mythtv-setup
             sudo systemctl enable --now mythbackend.service
-- 
cgit v0.12

