#!/usr/bin/env bash VERS='3.03042023' MMFOLDER="/opt/idssys/mediamanager" MMSRV=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) noheader=' check noup stop ' declare -A NM_SERVICES NM_SERVICES['openvpn']='OpenVPN (TorGuard VPN Tunnel)' NM_SERVICES['wireguard']='WireGuard (TorGuard VPN Tunnel)' NM_SERVICES['lidarr']='Lidarr (Music Manager)' NM_SERVICES['radarr']='Radarr (Movie Manager)' NM_SERVICES['radarr3d']='Radarr3D (3D Movie Manager)' NM_SERVICES['sonarr']='Sonarr (TV Show Manager)' NM_SERVICES['bazarr']='Bazarr (Subtitle Manager)' NM_SERVICES['jackett']='Jackett (Torrent Indexing Manager)' NM_SERVICES['qbittorrent']='qBittorrent (Torrent Downloader)' NM_SERVICES['snap.tautulli.tautulli']='Tautulli (Plex Stats)' NM_SERVICES['ombi']='Ombi (Download Requester)' if [ "${VPN_INTERFACE}" = "tun0" ]; then #openvpn VPN_START=(/bin/systemctl start openvpn) VPN_STOP=(/bin/systemctl stop openvpn) else #default wireguard VPN_START=(/usr/bin/wg-quick up ${VPN_INTERFACE}) VPN_STOP=(/usr/bin/wg-quick down ${VPN_INTERFACE}) fi DEBUGLOGSTOP(){ chktmend=`date +%s` chktm=$((chktmend-chktmstart)) echo "$(date) - ${mmsv} Runtime: ${chktm}s" >> $logfile } MMUPDATECHECK(){ if curl -m 15 -s --head --request GET https://git.schroedercity.com | grep "HTTP/2 200" > /dev/null; then cd ${MMFOLDER} if [ "`git log --pretty=%H ...refs/heads/master^ | head -n 1`" != "`git ls-remote origin -h refs/heads/master |cut -f1`" ]; then touch ${MMFOLDER}/update.available fi else /bin/rm -f ${MMFOLDER}/update.available fi } SENDNOTICE(){ # [ "${EMAIL_NOTICE}" != "" ] && echo -e "${2}\n\n$(date)" | mail -s "${1}" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && push_to_mobile "${2} $(date)" "${1}" ${3} } uptime_minutes() { set `uptime -p` local minutes=0 shift while [ -n "$1" ]; do case $2 in day*) ((minutes+=$1*1440));; hour*) ((minutes+=$1*60));; minute*) ((minutes+=$1));; esac shift shift done echo $minutes }