<div dir="ltr"><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 7, 2024 at 11:16 AM Bill Meek <<a href="mailto:keemllib@gmail.com" target="_blank">keemllib@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><span></span><br><br>On 
Wednesday 07 August 2024 09:27:57 AM (-05:00), James Abernathy 
wrote:<br><br><blockquote style="margin:0px 0px 0.8ex;border-left:2px solid rgb(0,0,255);padding-left:1ex"><div dir="ltr">On my test mythtv backend I'm 
trying to set up to use ntfy.sh. I seem to have a permissions issue that 
I'm not able to fix.<div><br></div><div>I set up my database using the 
following mysql 
instructions:</div><div><br></div><div>mythtv_password=mythtv <br></div><div>sudo 
mysql -uroot << ENDOFSCRIPTINPUT<br>CREATE DATABASE IF NOT EXISTS 
mythconverg;<br>CREATE USER IF NOT EXISTS 'mythtv'@'%' IDENTIFIED BY 
'mythtv';<br>CREATE USER IF NOT EXISTS 'mythtv'@'localhost' IDENTIFIED BY 
'mythtv';<br>SET PASSWORD FOR 'mythtv'@'%' = 
PASSWORD('$mythtv_password');<br>SET PASSWORD FOR 'mythtv'@'localhost' = 
PASSWORD('$mythtv_password');<br>CONNECT mythconverg;<br>GRANT ALL 
PRIVILEGES ON *.* TO 'mythtv'@'%' WITH GRANT OPTION;<br>GRANT ALL 
PRIVILEGES ON *.* TO 'mythtv'@'localhost' WITH GRANT OPTION;<br>FLUSH 
PRIVILEGES;<br>EXIT<br>ENDOFSCRIPTINPUT<br></div><div><br></div><div>This 
works for using mythtv backend and frontend. However, when running my 
backup script I see:</div><div><br></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0)">[mythtv@nucboxg3 ~]$ mythtv-database-backup.sh 
 </span><br>/usr/bin/mariadb-check: Got error: 1045: Access denied for 
user 'mythtv'@'localhost' (using password: NO) when trying to connect<br>
<br></span></div><div><span style="font-family:monospace">This is the 
script that I can either run as user mythtv normally or in a systemd 
service with a timer. When run by systemd everything works except for the 
mariadb-check so until I checked the logs I didn't know it wasn't working 
because I was getting the backups and notifications.</span></div><div><span style="font-family:monospace"> </span></div><div>#!/bin/sh<br># 
/etc/cron.weekly/mythtv-database script - check and backup mythconverg 
tables<br># Copyright 2005/12/02 2006/10/08 Paul Andreassen<br>#   
                   2010 
Mario Limonciello<br>set -e 
-u<br>DBNAME="mythconverg"<br>USER=mythtv<br>BKUP_LOG=/tmp/backup-mythconverg.log<br>export 
MYTHCONFDIR=/home/$USER/.mythtv/<br>/usr/bin/mariadb-check -s 
$DBNAME<br>/usr/local/bin/<a href="http://optimize_mythdb.pl" target="_blank">optimize_mythdb.pl</a> | grep -v 
"^Analyzed:" 2>&1 >> $BKUP_LOG<br>sudo --preserve-env 
--user=$USER /usr/share/mythtv/<a href="http://mythconverg_backup.pl" target="_blank">mythconverg_backup.pl</a> --rotate=5 
--verbose 2>&1 >> $BKUP_LOG<br>if [ $? -eq 0 ]; then<br>  
  MSG="nucboxg3 $DBNAME Checked and Backed Up, 
RC=$?"<br>else<br>    MSG="nucboxg3 $DBNAME Back Up Failed, 
RC=$?"<br>fi<br>cd /mythtv/db_backups<br>ls -l --directory --block-size=K * 
| tail -10 >> $BKUP_LOG<br>bash <(curl -d "$MSG" <a href="http://ntfy.sh/jfa-mythtv-database-backup" target="_blank">ntfy.sh/jfa-mythtv-database-backup</a>)<br></div><div><br></div><div>What 
am I missing?</div><div><br></div><div>Jim 
A</div></div></blockquote><div><br></div><span style="font-size:medium">The /usr/bin/mariadb-check -s $DBNAME  above has no password. 
I assume your .service file has</span><div><font size="3">a User=mythtv 
line in it.</font></div><div><font size="3"><br></font><div><font size="3">Test: /</font><span style="font-size:medium">usr/bin/mariadb-check</span><span style="font-size:medium">  mythconverg </span><span style="font-size:medium">as 
that user.  Maybe your</span></div><div><span style="font-size:medium">user has a .my.cnf file with the password etc. and user mythtv 
doesn't?</span></div><div><div><blockquote style="margin:0px 0px 0.8ex;border-left:2px solid rgb(0,0,255);padding-left:1ex"><div dir="ltr"><div></div></div></blockquote><span><br>-- <br>Bill</span></div></div></div></div><br></blockquote><div> </div><div>I've tried with and without the User=mythtv statement and have had no success including it.</div><div><br></div><div>Part of the problem is when the log file in /tmp get's created it takes on the permissions of the creator so I have to remember to delete it before another test.</div><div><br></div><div>At this point the service below runs correctly if it runs without the User=mythtv statement.</div><div><br></div><span style="font-family:monospace;color:rgb(0,0,0)"># This service unit is for backing up the mythtv database called mythconverg
</span><br><font face="monospace">#
</font><br><font face="monospace">[Unit]
</font><br><font face="monospace">Description=Backup MythTV Database 'mythconverg'
</font><br><font face="monospace">Requires=mysql.service
</font><br><font face="monospace">After=mysql.service
</font><br>
<br><font face="monospace">[Service]
</font><br><font face="monospace">Type=oneshot
</font><br><font face="monospace">ExecStart=/usr/local/bin/mythtv-database-backup.sh</font><br>
---------------<br><span style="font-family:monospace">/usr/local/bin/mythtv-database-backup.sh</span><span style="font-family:monospace"> is as follows:</span></div><div class="gmail_quote"><font face="monospace">---------</font></div><div class="gmail_quote"><font face="monospace">#!/bin/bash<br>set -e -u<br>DBNAME="mythconverg"<br>USER=mythtv<br>BKUP_LOG=/tmp/backup-mythconverg.log<br>export MYTHCONFDIR=/home/$USER/.mythtv/<br>/usr/bin/mariadb-check $DBNAME 2>&1 > $BKUP_LOG<br>/usr/local/bin/<a href="http://optimize_mythdb.pl">optimize_mythdb.pl</a> | grep -v "^Analyzed:" 2>&1 >> $BKUP_LOG<br><br>sudo --preserve-env --user=$USER /usr/share/mythtv/<a href="http://mythconverg_backup.pl">mythconverg_backup.pl</a> --rotate=5 --verbose 2>&1 >> $BKUP_LOG<br>if [ $? -eq 0 ]; then<br>    MSG="nucboxg3 $DBNAME Checked and Backed Up, RC=$?"<br>else<br>    MSG="nucboxg3 $DBNAME Back Up Failed, RC=$?"<br>fi<br>cd /mythtv/db_backups<br>ls -l --directory --block-size=K * | tail -10 >> $BKUP_LOG</font><br><div> </div><div>I have no idea why the sudo with the options works on the <a href="http://mythconverg_backup.pl">mythconverg_backup.pl</a> statement. I think I've modified this from others smarter than me.</div><div><br></div><div>I don't know what the my.cnf file is and where I should find it.  So if I need one I probably don't.</div><div><br></div><div>JIm A</div></div></div>
</div>