From 09c491757cc31cc4b44967f4df50b56a06b218c3 Mon Sep 17 00:00:00 2001 From: Britney Fransen Date: Wed, 30 Nov 2022 18:10:41 -0500 Subject: linhes-dev: mp.py: use updpkgsums to replace sums --- linhes/linhes-dev/PKGBUILD | 13 +++--- linhes/linhes-dev/mp.py | 73 +++---------------------------- linhes/linhes-system/PKGBUILD | 17 ++++--- linhes/linhes-system/diskspace.sh | 2 +- linhes/linhes-system/lh_system_start.sh | 64 +++++++++++++++++---------- linhes/linhes-system/linhes-profile.sh | 3 ++ linhes/linhes-system/optimize_mythdb.py | 16 +++++++ linhes/linhes-system/x11vnc.override.conf | 10 +++++ 8 files changed, 94 insertions(+), 104 deletions(-) create mode 100644 linhes/linhes-system/linhes-profile.sh create mode 100755 linhes/linhes-system/optimize_mythdb.py create mode 100644 linhes/linhes-system/x11vnc.override.conf diff --git a/linhes/linhes-dev/PKGBUILD b/linhes/linhes-dev/PKGBUILD index 33a906d..df74320 100644 --- a/linhes/linhes-dev/PKGBUILD +++ b/linhes/linhes-dev/PKGBUILD @@ -1,19 +1,20 @@ pkgname=linhes-dev pkgver=9.0.0 -pkgrel=6 +pkgrel=7 pkgdesc="Scripts to develop LinHES" arch=('x86_64') license=('GPL2') -depends=('clean-chroot-manager' 'git' 'python-gitpython' 'rclone' 'yaah') +depends=('clean-chroot-manager' 'git' 'pacman-contrib' + 'python-gitpython' 'rclone' 'yaah') url="http://linhes.org/" source=('lh_sync.sh' 'mp.py' 'lh_setup_dev.sh' 'lh_update_db_repo.sh') +sha256sums=('3a64b4125b56c6f95cc9dc85ce58ebd1c0612b22fb27c3e76d4d9a5570f2d61e' + '16787763282f20b15eee2377712e85d5653a9229d2b73d224c0fd4532436614a' + '081ac1ccb40df0c8aa82cd3841a39aa87ead4ea32c9ac6a76c5a7d7f0d10a80a' + '86c9ebe77228f7e3cc07cb05f480e5584e0e3cad1b889b63a50821f7323bf449') package() { cd ${srcdir} install -d ${pkgdir}/usr/bin install -D -m755 * ${pkgdir}/usr/bin/ } -sha256sums=('3a64b4125b56c6f95cc9dc85ce58ebd1c0612b22fb27c3e76d4d9a5570f2d61e' - 'd7afe023b5ba5ebb5e1a12d954651e435584034e5b00c37d9a70d0d6fe20643f' - '081ac1ccb40df0c8aa82cd3841a39aa87ead4ea32c9ac6a76c5a7d7f0d10a80a' - '86c9ebe77228f7e3cc07cb05f480e5584e0e3cad1b889b63a50821f7323bf449') diff --git a/linhes/linhes-dev/mp.py b/linhes/linhes-dev/mp.py index b1bdfa7..25f7cc0 100755 --- a/linhes/linhes-dev/mp.py +++ b/linhes/linhes-dev/mp.py @@ -41,13 +41,12 @@ def commandline(makepkg_cmd): clparser.add_option("-b", "--bump", action="store_true", default=False, help="Increase package release one unit.") clparser.add_option("--pkglist", action="store", help="List of packages to compile") clparser.add_option("--config", action="store", help="Use an alternate config file instead of the /etc/makepkg.conf default.") - clparser.add_option("-g", "--geninteg", action="store_true", default=False, help="For each source file in the source array of PKGBUILD, download the file if required and generate integrity checks.") clparser.add_option("--rmold", action="store_true", default=False, help="BETA: Remove old src and software packages from repos. Use with caution. False positives may occur (i.e. nvidia pkgs)!") (options, args) = clparser.parse_args() options1 = ['config', 'pkglist'] - options2 = ['bump', 'geninteg', 'rmold'] + options2 = ['bump', 'rmold'] for o in options1: cmd1 = eval('options.'+o) @@ -74,10 +73,6 @@ def commandline(makepkg_cmd): # Remove rmold option from makepkg command if it exists if "--rmold" in makepkg_cmd: makepkg_cmd.remove("--rmold") - # Remove "--geninteg" option (if it exists) from makepkg command. - # Checking for *sums is done automaticly by mp.py - if "--geninteg" in makepkg_cmd: - makepkg_cmd.remove("--geninteg") #print("Makepkg Command:",makepkg_cmd) return makepkg_cmd, cli_list, cli_dict @@ -135,7 +130,6 @@ class Packagefile(object): self.SRCPKG = self.pkgbase + "-" + self.epoch + self.pkgver + "-" + self.pkgrel + ".src.tar.gz" else: self.SRCPKG = self.pkglist[0] + "-" + self.epoch + self.pkgver + "-" + self.pkgrel + ".src.tar.gz" - #print "Changed " + self.pkgname + " release to " + str(self.pkgrel) def updateINIT(self): @@ -310,64 +304,12 @@ class Packagefile(object): self.set_srcpkg() self.pkgrel_incremented = True - def clearSUMS(self): - print(" Clearing out old checksums...") - filename=self.pkgfile - file_contents=[] - f = open(filename,"r") - lineIter= iter(f) - for aLine in lineIter: - if (aLine.strip().startswith("md5sums") or aLine.strip().startswith("sha1sums") or - aLine.strip().startswith("sha256sums") or aLine.strip().startswith("sha224sums") or - aLine.strip().startswith("sha384sums") or aLine.strip().startswith("sha512sums") or - aLine.strip().startswith("b2sums") or aLine.strip().startswith("cksums")): - if aLine.strip().endswith(")"): - continue - else: - for aModule in lineIter: - if aModule.strip().endswith(")"): - break - else: - file_contents.append(aLine) - f.close() - try: - f = open(filename,"w") - except: - outtext="Couldn't open file for writing: %s" %filename - print(outtext) - return False - for line in file_contents: - f.write(line) - f.close() - def updateSUMS(self): - print("- Checking checksums...") - if "--geninteg" in self.cli_list: - self.clearSUMS() - - sums = [] - pkgfile_contents=[] - - # Open pkgfile for reading - f = open(self.pkgfile, 'r') - pkgfile_contents = f.readlines() - f.close() - - # Iterate through the lines looking for a match pattern - for line in pkgfile_contents: - check = re.compile('cksums|sha1sums|sha224sums|sha256sums|sha384sums|sha512sums|md5sums|b2sums') - sums = check.match(line) - if sums: - print(" Found checksums in PKGBUILD") - break - if not sums: - print(" Adding checksums...") - # If no matches are found, append md5sums to the end of the pkgfile - p = open(self.pkgfile, 'a') - sumsgen = subprocess.Popen(["makepkg", "-g"], stdout = subprocess.PIPE,).communicate()[0] - sumsgen = sumsgen.decode('utf-8') - p.writelines(sumsgen) - p.close() + print("- Updating checksums...") + retcode = subprocess.call(["updpkgsums"]) + if retcode != 0: + self.compile_status = "Failed: %s" %retcode + self.failure = self.failure + 1 def make_package(self): #creates both binary and source package @@ -390,9 +332,6 @@ class Packagefile(object): shutil.move(self.pkgfile + '.old', self.pkgfile) print(" Reverted pkgrel increment.") return False - elif "--nobuild" in self.makepkg_cmd: - self.compile_status = "Failed: nobuild" - return False else: print("-------------Making source package-------------") retcode = subprocess.call(["makepkg", "--force", "--holdver", "--source"]) diff --git a/linhes/linhes-system/PKGBUILD b/linhes/linhes-system/PKGBUILD index ec03819..c8c960a 100755 --- a/linhes/linhes-system/PKGBUILD +++ b/linhes/linhes-system/PKGBUILD @@ -1,21 +1,21 @@ pkgname=linhes-system pkgver=9.0.0 -pkgrel=3 +pkgrel=4 arch=('x86_64') #install=$pkgname.install pkgdesc="Everything that makes LinHES a system" license=('GPL2') -depends=('cronie' 'libnotify' 'linhes-templates' 'pacman-contrib' 'openssh' 'ttf-overlock') +depends=('cronie' 'dbus-python' 'libnotify' 'linhes-templates' '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 jobqueue_helper.py - diskspace.sh find_orphans.py + diskspace.sh find_orphans.py optimize_mythdb.py create_media_dirs.sh be_check.py myth2mkv myth2mp3" source=($binfiles 'myth_mtc.cron' 'paccache.cron' 'xfs_defrag.cron' 'readme_is_xml' 'add_storage.readme' '79-cronie.hook' 'fstrim.hook' 'openssh.hook' - '10-monitor.conf' + '10-monitor.conf' 'x11vnc.override.conf' 'system-sudo.rules' 'lh_system_start.sh.desktop') @@ -34,6 +34,9 @@ package() { #startup files install -D -m600 "$srcdir/lh_system_start.sh.desktop" "$pkgdir/home/mythtv/.config/autostart/lh_system_start.sh.desktop" + #systemd files + install -m644 -D $srcdir/x11vnc.override.conf $pkgdir/etc/systemd/system/x11vnc.service.d/override.conf + #readme files install -m644 -D $srcdir/readme_is_xml $pkgdir/etc/gen_is_xml.d/readme_is_xml install -m644 -D $srcdir/readme_is_xml $pkgdir/etc/gen_lib_xml.d/readme_gen_xml @@ -67,10 +70,11 @@ sha256sums=('96f67b5428debb7dac909893c56a7637bf6545c068732822981d4080125c53d9' '11168c9cd3b117decaab6bc665c183b4aab917cf0a976bce4c1b5e4686a27bc9' 'ae34515e144830f424d3bd3f6b1b446892d62beed20bca6f0fb19b0bbb779f27' '23358a7bff4968eccd469613b81b1415c2ae0ebe77f14f74426697333e4d88d7' - '3d75c92c19da1f21da751f6425d9403eae58a1f5f665b39d72e6d2ff0e9c5494' + '1178b1c9797c50e5808558a2e7c826bbc4243bbf81f09d94d36fa26124f921e0' '91bdec992bb2c933e15625c181f2195c402060b879168ebf35944cb064c904b9' - 'f046b10e9f8686a8f5d1a48220506c0e22cc3b630f787d9f5e6b9044a22e7b26' + 'cedd34e448d3d45ab0f9fff40c115401f45bdea5b99215d0aff514a759ae2b7c' '76f023c0cde7fea269234f1b29c32b117b91769217d4b1b8a3922daceb25f9f8' + 'e371c6a289c68fe200d7da856c20a8c579efa23178f4d62235f7359d7f6e49a1' 'bffcc13e4b480f720feb2b3c781bc4247c63303250c3d885022c699573d45a33' '0254a21644473ba7953501a223f13b9b55d7ec290c80a567724ca1ac13e02e30' '9ea1b5583cd38f53bb79d9e4ccae91a028db0b6850162d7991b19122c564b9c9' @@ -84,5 +88,6 @@ sha256sums=('96f67b5428debb7dac909893c56a7637bf6545c068732822981d4080125c53d9' '4c29e0b71071ae9556cf2dbd75de560d028577fe5eb993113105112c4b445eac' '890482242434e333024c7819e8bf3c889dc16548d0a1745479c8523930fb32f7' 'dead17906b33a7f9d66ad13bb1c083a23438f45ece9bd5ec41ff86eda01c132a' + '2c9152ed542bb9c3aa516c6009125a757065100a060e0fa597243d4cbd92844f' 'a9d0a94ff442453f0bec0b2e8afd591cf17b2845b6ae45ff300530114efd30af' '0b9868a563036c81f8fdb8ab8bbad51934aca2a07e9d7634e24214791afda8e2') diff --git a/linhes/linhes-system/diskspace.sh b/linhes/linhes-system/diskspace.sh index b48f59d..f28cf46 100755 --- a/linhes/linhes-system/diskspace.sh +++ b/linhes/linhes-system/diskspace.sh @@ -15,7 +15,7 @@ DF='/usr/bin/df' GREP='/usr/bin/grep' AWK='/usr/bin/awk' CUT='/usr/bin/cut' -HOSTNAME='/usr/bin/hostname' +HOSTNAME='/usr/bin/hostnamectl hostname' DATE='/usr/bin/date' MSG_CLIENT='/usr/bin/notify-send' diff --git a/linhes/linhes-system/lh_system_start.sh b/linhes/linhes-system/lh_system_start.sh index 6ba1cb0..e3243a5 100755 --- a/linhes/linhes-system/lh_system_start.sh +++ b/linhes/linhes-system/lh_system_start.sh @@ -23,40 +23,55 @@ function applyUIsettings(){ msg "Welcome to LinHES 9!" } -function make_nanorc(){ +function x11vnc_setup(){ + msg "Set x11vnc Password" "Open Konsole run x11vnc -storepasswd" + touch ~/.vnc/x11vnc.log + /usr/bin/systemctl enable --now x11vnc.service +} + +function bashrc_setup(){ + if ! grep -q 'alias rscp=' ~/.bashrc; then + echo -e "\nalias rscp='rsync -a --info=progress2'" >> ~/.bashrc + fi + if ! grep -q 'alias rsmv=' ~/.bashrc; then + echo -e "alias rsmv='rsync -a --info=progress2 --remove-source-files'" >> ~/.bashrc + fi +} + +function nanorc_setup(){ mkdir ~/.config/nano echo -e 'set tabsize 4\nset tabstospaces\ninclude "/usr/share/nano/*.nanrc"' >> ~/.config/nano/nanorc } -function notify_scan(){ - if [ -e /tmp/scan_report ] - then +function storage_scan(){ + if [ -e /tmp/scan_report ]; then msg "New Storage Found" "Run add_storage.py for details." fi } +function install_lh_apps(){ + #install programs that are not needed on the iso + sudo pacman -Syyy firefox glances mythtv ncdu x11vnc +} + function first_configure(){ - echo "First configure..." - if [ ! $SystemType = "Frontend_only" ] - then - if [ ! -f ~/.config/lh_configured ] - then - applyUIsettings - msg "New install of LinHES. Starting setup." + if [ ! -f ~/.config/lh_configured ]; then + #apply settings for all system types + applyUIsettings + msg "New install of LinHES. Starting setup." + nanorc_setup + bashrc_setup + x11vnc_setup + + #apply settings for specific system types + if [ ! $SystemType = "Frontend_only" ]; then # only run mythfilldatabase for masterbackends - if [ $SystemType = "Master_backend" ] - then - #nice -n 19 mythfilldatabase --quiet & - msg "Guide data is being loaded." "Until this completes some shows will appear as unknown in the program guide." - fi - touch ~/.config/lh_configured - fi - else - if [ ! -f ~/.config/lh_configured ] - then - applyUIsettings - touch -f ~/.config/lh_configured + #nice -n 19 mythfilldatabase --quiet & + msg "Guide data is being loaded." "Until this completes some shows will appear as unknown in the program guide." + else + #Frontend_only cmds fi + touch ~/.config/lh_configured fi } @@ -65,4 +80,5 @@ function first_configure(){ #-------MAIN------- first_configure /usr/bin/enableIRWake.sh & -notify_scan +xset -dpms s off +storage_scan diff --git a/linhes/linhes-system/linhes-profile.sh b/linhes/linhes-system/linhes-profile.sh new file mode 100644 index 0000000..00baeac --- /dev/null +++ b/linhes/linhes-system/linhes-profile.sh @@ -0,0 +1,3 @@ +#!/bin/bash +#this enables airplay support +export MYTHTV_AIRPLAY="1" diff --git a/linhes/linhes-system/optimize_mythdb.py b/linhes/linhes-system/optimize_mythdb.py new file mode 100755 index 0000000..7d60e89 --- /dev/null +++ b/linhes/linhes-system/optimize_mythdb.py @@ -0,0 +1,16 @@ +#!/usr/bin/python +# import MySQL module +import MySQLdb +import socket +import sys +db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg") +cursor = db.cursor() +cursor.execute("SHOW tables") +result = cursor.fetchall() +ops=["REPAIR","OPTIMIZE","ANALYZE"] +for row in result: + ctable=row[0] + for op in ops: + print(op,ctable) + cmd= "%s table %s" %(op,ctable) + cursor.execute(cmd) diff --git a/linhes/linhes-system/x11vnc.override.conf b/linhes/linhes-system/x11vnc.override.conf new file mode 100644 index 0000000..f79e9c8 --- /dev/null +++ b/linhes/linhes-system/x11vnc.override.conf @@ -0,0 +1,10 @@ +[Service] +ExecStart= +Type=forking +ExecStart=/usr/bin/x11vnc -nap -wait 50 -noxdamage -rfbauth /home/mythtv/.vnc/passwd -display :0 -nocursor -forever -o /home/mythtv/.vnc/x11vnc.log -bg +Restart=on-failure +RestartSec=10 +User=mythtv + +[Install] +WantedBy=graphical.target -- cgit v0.12