pkgname=linhes-system
pkgver=9.0.0
pkgrel=103
arch=('x86_64')
#install=$pkgname.install
pkgdesc="Everything that makes LinHES a system"
license=('GPL2')
depends=('cronie' 'dbus-python' 'dvb-firmware' 'expect' 'flatpak' 'firefox' 'glances' 'inetutils' 
         'kdialog' 'kwalletmanager' 'libnotify'
         'logrotate' 'linhes-templates' 'linhes-theme' 'mlocate' 'moreutils' 'ncdu' 'pacman-contrib'
         'plasma-x11-session' 'python-dateutil' 'python-pytz' 'python-tzlocal' 'openssh'
         'rsyslog' 'ttf-overlock' 'wget' 'x11vnc'
         'intel-media-driver' 'libva-intel-driver' 'pigz')
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
          lh_home_check.sh lh_myth_status.py lh_system_backup lh_system_backup_job
          jobqueue_helper.py gen_lib_xml.py lh_setup_fileshare.py lh_restart_needed.sh
          diskspace.sh find_orphans.py optimize_mythdb.py lh_mtc.py lh_apply_UI_settings.sh
          misc_recent_recordings.pl misc_status_config.py misc_status_info.sh
          misc_upcoming_recordings.pl misc_which_recorder.pl plexmediascanner.sh
          create_media_dirs.sh be_check.py
          myth2mkv myth2mp3 myth2videos udev_link.sh"
source=($binfiles
    'lh_mtc.cron' 'paccache.cron' 'flatpak_update.cron' 'xfs_defrag.cron' 'pacman_orphans.cron'
    'readme_is_xml' 'add_storage.readme' 'LinHES-release' 'lh_log_care.cron'
    '79-cronie.hook' 'fstrim.hook' 'openssh.hook' 'plex_lib.conf' 'rsyslog.hook'
    '10-monitor.conf' '81-wol.rules' '69-hdparm.rules' 'x11vnc.override.conf' 'lh_lighttpd.conf' 'lh_php.ini'
    'system-sudo.rules' 'linhes-profile.sh' 'lh_sqlserver.cnf' 'lh_restart_needed.hook'
    'lh_system_start.sh.desktop' 'rc6_mce.toml' 'recordings.cron' 'rsyslog.mythtv.conf')
sha256sums=('1fb11c7f472df9e3066866301962c2678b80c2fbd988dc34db022d51e1101a42'
            '8ae6de3d0ff8e777aeea56f74f38676080142148ac3a32f828462d85c39e7cf7'
            '79a3fe8622dbc5351316c0e36c26f8443334fcf8eea324cf0a0efe0e4c2c1a93'
            'ff261f41efec8a9963f9f59100cbe75f015028a2ed3a863ce0cb473f2ebb7b76'
            '8b54c31b8efde3917f603c5307bebb0a2a00239ad9a983c2f5d8120003256449'
            'ae34515e144830f424d3bd3f6b1b446892d62beed20bca6f0fb19b0bbb779f27'
            'a79edfeb88b90a8f5538a159b39ba235caba8c6d6b2a39a20faa3ae0301b770b'
            '575ae8455b4862f68454516718ddb0531755f194ac278794f9ba175da5a30cab'
            '1c36e4fdf41c1063e0a127ce4a90fbdef19879c381a87f622d7399ca931560cc'
            '87875d9e5f5ce18208f419698ce69b6bcbcd08955a57a4a13940e715af58b787'
            '192bfff1b8d46e0ebb969618847d9993aba3b1b578053c8d701dad9f9e758f86'
            'a523388ffdc6f30f2dd2ef4803b21bded8a35bfded499dc66b786adec71840a3'
            'eec03b722449a55e589eb79aade87e9b2a964e82b8fe23723016b640a079de2a'
            '91bdec992bb2c933e15625c181f2195c402060b879168ebf35944cb064c904b9'
            '5cacfdd02833e5a3130d765573e772e6bd5030336ba86239c5e4db5ffa36fc69'
            'd51253c207d3315997d7122cb774c6d0fc38975c33e66bf416f0b1b95cf86e5b'
            'f3d65c821ccddb5305e4338ce3fa7072d04d0af394d8061234bbac529a6b9abd'
            'ebdb3ee0212e0cc72526bb5e50a032573e1894acb7bf75617243b0b49aa1f8f2'
            'cd3306991c8b63f5402c0e52405cc1a6581cb3c42af74b7c2f879c8192f95610'
            'e371c6a289c68fe200d7da856c20a8c579efa23178f4d62235f7359d7f6e49a1'
            'ee9a4df83e463e0c8a2e862680a83cff07a36cf3606faf60f57bc11190ffb1c9'
            'c801a69df165ca152f6e0de14fd7e24358ee9891732c9f0d10f65e73329e5db5'
            'd2d69b2bf6315bd37ff5f5b2f0cde8ab2fb89bae18f8796dc5208ffc1a9d743e'
            'a745356952470a5d718bef1961309ea30e4fa6a2860961cd52e09d6ec11e708e'
            '1819085bd2c9106482c5f243b95fddf3dae69212330ab76cb493add5c26a45a4'
            '62a5a195ddfaa13bbc7b5bc627cdd748f5d697d178a5238b71a703533bfdd587'
            '8d92160ef094c6186cb0aaeeddcf8730f3e1a05a933ad4147269a74f09c70b19'
            'bfb0cc87bf350214f38a262400bee0174fca75f15bed4eec6bdad4a34dde174c'
            'bffcc13e4b480f720feb2b3c781bc4247c63303250c3d885022c699573d45a33'
            '51093acab5e5a4de51a55f4bdf7b935f4f69edf3d84f1c37db710853ec95eca8'
            'ad4ddabbc34d5e1b308ece33cabf91d750f44894c52a18325762dea026152973'
            'a961cfdc6f02b12fb445777dd2c144fed96306ca2f430cc8853ae307c759c1ad'
            'd8574104b75c6d41284488612ec5583c50a8dab438492fa42c47231add4cfc54'
            '6bdbf593d3e1348d1a8f7c4c17cb2e893f7e18ae355daf978173e669cfe3be80'
            'bc6b23e799f22fa16cfc37a91a5f06503beb80db3eeb420c766f7b3d41ba8356'
            '186203d3c0520bb3d611da99d33a7713e9c1563814285f1f101097234f214b2f'
            'd8d36a501928d0cc505957d392291fad317b1e895ff99847d90643cf5f622a89'
            'cdfc0c836b8194f631f4a9e022c232ff75a13ff1a161a1a011858578bea5f930'
            '14c9e1e84a3f9ca182f3d848bd011c57d5332f9106eafcad74fc8cf8f97ef3d3'
            '5f502b1bc8815d69c802320790745e4526d5817fd8ecc7b00cf8b16078f8d440'
            '12e424432bdf2d50afe3e632c018fef847e860a35a53525eccbe656b9c4118aa'
            'ee745056d018f860572f8363ed5e730ba501394c23cdd6f316719d7141c10050'
            '77fc99fee33387a91e158c0a4e6f3d99601e4d27d04e26d3f815634f48de6a79'
            '0fbc05f521aea83157c5e6f8bd29a422873093bb6cded965cb7ffe98ff776fa4'
            '4c29e0b71071ae9556cf2dbd75de560d028577fe5eb993113105112c4b445eac'
            '890482242434e333024c7819e8bf3c889dc16548d0a1745479c8523930fb32f7'
            '71c564a12d9a8e2814a2bf67a1a3d70c1e9d3b50bc108f7043ed8c958c067b01'
            '6c42b2920c6a37bf3dd05755b9e3fdd80137708cc55a7d1bef2234c17dff0349'
            '09b9c1b2ee6a5bbe48c5f3755ad64628487b60a4eb6734efb292cefdb74fb657'
            'efc2a04b67ea76661157e154228d4b58ae2e1b652f8ce41bc001a5a863d13573'
            '7571e230ab4cf2a1285fdb9762d87d350ea350ce820e5806143b402aa1ea37e0'
            '67d0cb111d47609de4c60b84dc617fc817fdf092763fbd0cef270b5ee650d702'
            '023cba18580819018413608ec055d5ff8166b69525c32aa728ad1ecd7cf00aca'
            'dae799f09a076e0f573ea516bc357f56f2fd3aa8e35ec0cf54b6b62282960ee0'
            'aa1d831f25317a9cb8d7e9a7d7b6d51c8d03bd5b69f3bec27bea7644ca38fe9a'
            '2553c3a877b6b18eed8269d5d78bd5676cd52fa5ead5b99a02f42bd134f12040'
            '01416dadeb34ca8b18bb7326113672b3888b16a60133d501d48610d23b74d1eb'
            '197ff4bb3c1cafcb197268cac335f1f75ae26873aca5833d62cc51fade85176c'
            '0b9868a563036c81f8fdb8ab8bbad51934aca2a07e9d7634e24214791afda8e2'
            '1b965b5e7eeafdf3815c8f2722587a560693dd780327cca9910dc47fba0f1aef'
            'd09244af78e693cf0eaa14b7bd0d7535cb8f6c0a78eb0e1f0a0fd2bfd5ec56c1'
            '2b91f6eb8c010a0dce1f41149c0549d067915fba93251c7af7e5328a05977f0c')

package() {
    cd ${srcdir}

    install -m755 -D linhes-profile.sh ${pkgdir}/etc/profile.d/linhes-profile.sh

    #bin files
    BINDIR=${pkgdir}/usr/bin
    for i in $binfiles
    do
        item=$i
        echo "installing $item to $BINDIR"
        install -m755 -D $item $BINDIR/$item
    done

    #release files
    install -Dm644 "${srcdir}/LinHES-release" "${pkgdir}/etc/LinHES-release"

    #startup files
    install -Dm644 "${srcdir}/lh_system_start.sh.desktop" "${pkgdir}/etc/skel/.config/autostart/lh_system_start.sh.desktop"

    #systemd files
    install -Dm644 ${srcdir}/x11vnc.override.conf ${pkgdir}/etc/systemd/system/x11vnc.service.d/override.conf

    #sql files
    install -Dm644 ${srcdir}/lh_sqlserver.cnf ${pkgdir}/etc/my.cnf.d/lh_sqlserver.cnf

    #php files
    install -Dm644 ${srcdir}/lh_php.ini ${pkgdir}/etc/php/conf.d/lh_php.ini

    #lighttpd files
    install -Dm644 ${srcdir}/lh_lighttpd.conf ${pkgdir}/etc/lighttpd/conf.d/lh_lighttpd.conf

    #gen_lib_xml.py files
    install -Dm644 ${srcdir}/plex_lib.conf ${pkgdir}/etc/gen_lib_xml.d/plex_lib.conf

    #rsyslog files
    install -Dm644 ${srcdir}/rsyslog.mythtv.conf ${pkgdir}/etc/rsyslog.d/mythtv.conf

    #remote files
    install -Dm644 ${srcdir}/rc6_mce.toml ${pkgdir}/etc/rc_keymaps/rc6_mce.toml

    #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
    install -Dm644 ${srcdir}/readme_is_xml ${pkgdir}/etc/gen_game_xml.d/readme_gen_xml
    install -Dm644 ${srcdir}/add_storage.readme ${pkgdir}/etc/storage.d/readme

    #cron files
    install -Dm755 ${srcdir}/paccache.cron ${pkgdir}/etc/cron.weekly/paccache
    install -Dm755 ${srcdir}/pacman_orphans.cron ${pkgdir}/etc/cron.weekly/pacman_orphans
    install -Dm755 ${srcdir}/xfs_defrag.cron ${pkgdir}/etc/cron.weekly/xfs_defrag
    install -Dm755 ${srcdir}/lh_mtc.cron ${pkgdir}/etc/cron.hourly/lh_mtc
    install -Dm755 ${srcdir}/flatpak_update.cron ${pkgdir}/etc/cron.daily/flatpak_update
    install -Dm755 ${srcdir}/lh_log_care.cron ${pkgdir}/etc/cron.daily/lh_log_care
    install -Dm755 ${srcdir}/recordings.cron ${pkgdir}/etc/cron.hourly/recordings

    #hooks
    install -Dm0644 ${srcdir}/79-cronie.hook "${pkgdir}"/usr/share/libalpm/hooks/79-cronie.hook
    install -Dm0644 ${srcdir}/fstrim.hook "${pkgdir}"/usr/share/libalpm/hooks/fstrim.hook
    install -Dm0644 ${srcdir}/openssh.hook "${pkgdir}"/usr/share/libalpm/hooks/openssh.hook
    install -Dm0644 ${srcdir}/lh_restart_needed.hook "${pkgdir}"/usr/share/libalpm/hooks/lh_restart_needed.hook
    install -Dm0644 ${srcdir}/rsyslog.hook "${pkgdir}"/usr/share/libalpm/hooks/rsyslog.hook

    #sudo rules
    install -Dm0440 "${srcdir}/system-sudo.rules" "${pkgdir}/etc/sudoers.d/system_sudo"
    chmod 750 ${pkgdir}/etc/sudoers.d/

    #udev rules
    install -Dm0644 "${srcdir}/69-hdparm.rules" "${pkgdir}/etc/udev/rules.d/69-hdparm.rules"
    install -Dm0644 "${srcdir}/81-wol.rules" "${pkgdir}/etc/udev/rules.d/81-wol.rules"

    #disable dpms
    install -Dm0644 "${srcdir}/10-monitor.conf" "${pkgdir}/etc/X11/xorg.conf.d/10-monitor.conf"
}
