dotfiles

*nix config files
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

commit d87c94c6458dc56915ff06bce67fe98fe5ebffa6
parent 711f9b4881aded671379aa741a30e4783c8c7742
Author: pyratebeard <root@pyratebeard.net>
Date:   Thu, 25 Feb 2021 16:39:19 +0000

cronjobs

Diffstat:
Abin/bin/bgchange | 10++++++++++
Abin/bin/boat_sync | 9+++++++++
Mbin/bin/checkip | 22++++++++++++++++------
Abin/bin/daily_backup | 2++
Mbin/bin/mail_sync | 37+++++++++++++++++++++++++------------
Abin/bin/powerdl | 25+++++++++++++++++++++++++
Abin/bin/weather | 13+++++++++++++
Acron/var/spool/cron/pyratebeard | 27+++++++++++++++++++++++++++
8 files changed, 127 insertions(+), 18 deletions(-)

diff --git a/bin/bin/bgchange b/bin/bin/bgchange @@ -0,0 +1,10 @@ +#!/bin/bash + +export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus +colours=("202f2c" "362124" "363145") + +num=${#colours[@]} +random=$(( ( RANDOM % $num ) )) +new_colour=${colours[$random]} + +xsetroot -solid "#${new_colour}" diff --git a/bin/bin/boat_sync b/bin/bin/boat_sync @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus +/usr/bin/newsboat -x reload +sleep 10 + +#if [ ! -f ~/.newsboat/cache.db.lock ] ; then +# rsync -azu ~/.newsboat/cache.db blacksun:newsboat/cache.db +#fi diff --git a/bin/bin/checkip b/bin/bin/checkip @@ -1,13 +1,23 @@ #!/usr/bin/zsh + ipCmd=$(dig +short myip.opendns.com @resolver1.opendns.com) ipFile="/tmp/current_ip" -if [ ! -f $ipFile ] ; then - echo "$ipCmd" > $ipFile +if [ $# -eq 0 ] ; then + if [ ! -f $ipFile ] ; then + echo "$ipCmd" > $ipFile + fi + + if [[ $ipCmd != $(cat $ipFile) ]] ; then + echo "vpn ip has changed to $ipCmd" | mutt -s "vpn ip" root@pyratebeard.net + echo "$ipCmd" > $ipFile + fi +else + while getopts "c" opt ; do + case ${opt} in + c) echo ${ipCmd} ;; + esac + done fi -if [[ $ipCmd != $(cat $ipFile) ]] ; then - echo "vpn ip has changed to $ipCmd" | mutt -s "vpn ip" root@pyratebeard.net - echo "$ipCmd" > $ipFile -fi diff --git a/bin/bin/daily_backup b/bin/bin/daily_backup @@ -0,0 +1 @@ +/home/pyratebeard/src/securebak/daily_backup +\ No newline at end of file diff --git a/bin/bin/mail_sync b/bin/bin/mail_sync @@ -1,14 +1,27 @@ #!/usr/bin/env bash -mail_dir="$HOME/lib/doc/email" - -offlineimap -f INBOX >/dev/null 2>&1 -sleep 5 - -for inbox in pyratebeard octotech ; do - new_mail=$(ls -l ${mail_dir}/${inbox}/INBOX/new | wc -l) - let new_mail=new_mail-1 - if [ ${new_mail} -gt 0 ] ; then - /usr/bin/notify-send -u 'normal' "${new_mail} new mail(s) for ${inbox}" - fi -done +export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus +mail_dir="$HOME/lib/documents/email" +log_file="/var/log/mail_sync.log" +cached_key=$(gpg-connect-agent 'keyinfo --list' /bye 2>/dev/null | awk 'BEGIN{CACHED=0} /^S/ {if($7==1){CACHED=1}} END{if($0!=""){print CACHED} else {print "none"}}') + +log() { + echo "$(date +%H:%M:%S): ${1}" >> ${log_file} +} + +if [[ "${cached_key}" == "1" ]] ; then + log "INFO: gpg key cached, beginning sync" + offlineimap -f INBOX >/dev/null 2>&1 + sleep 5 + + for inbox in pyratebeard ; do + new_mail=$(ls -l ${mail_dir}/${inbox}/INBOX/new | wc -l) + let new_mail=new_mail-1 + if [ ${new_mail} -gt 0 ] ; then + /usr/bin/notify-send -u 'normal' "${new_mail} new mail(s) for ${inbox}" + fi + done +else + log "ERROR: no gpg key cached" +fi + diff --git a/bin/bin/powerdl b/bin/bin/powerdl @@ -0,0 +1,25 @@ +#!/bin/bash + +mixcloud_url="https://www.mixcloud.com/Gentlemanofmetal/" +mixcloud_show_prefix="powerzone-show-" +powerzone_url="https://powerzonemetal.uk/" +powerzone_show_prefix="" +powerzone_dir="$HOME/lib/music/powerzone" + +show_num=$(curl -s ${powerzone_url} | grep "<h4>Show #" | head -n1 | awk -F\# '$2>0 {print substr($2,1,3)}') +if [[ ! $(find ${powerzone_dir} -name "powerzone-*${show_num}-*.mp3" | wc -l) -eq 0 ]] ; then + echo "file exists" + exit 0 +fi + +if [[ ${show_num} =~ ^[0-9]+([.][0-9]+)?$ ]] ; then + powerzone_show_prefix="shows/show-" +else + powerzone_show_prefix="shows/" +fi +mixcloud_show_url=$(curl -s "${powerzone_url}${powerzone_show_prefix}${show_num}/" | grep mixcloud | grep feed | awk -F\= '{print $5}' | awk -F\& '{print $1}' | sed 's/%3A/\:/' | sed 's&%2F&/&g') +download_filename=$(echo ${mixcloud_show_url} | awk -F\/ '{print $5}') + +youtube-dl -q -o "${powerzone_dir}/${download_filename}" "${mixcloud_show_url}" +ffmpeg -loglevel quiet -i ${powerzone_dir}/${download_filename} -metadata title="${download_filename}" -metadata artist="powerzone" -metadata album="powerzone" -metadata track="${show_num}" -metadata genre="metal" "${powerzone_dir}/${download_filename}.mp3" +rm -f "${powerzone_dir}/${download_filename}" diff --git a/bin/bin/weather b/bin/bin/weather @@ -0,0 +1,13 @@ +#!/bin/sh + +weather() { + local -r location="$(curl -s "https://ipvigilante.com/" | jq -r '.data.city_name')" + wttr=$(curl -s "wttr.in/${location}?format=%l:+%f+%C\n" | tr '[:upper:]' '[:lower:]') + if [[ ${wttr} == "unknown location"* ]] ; then + echo -e "weather is ${light_red}unavailable${reset}" > /tmp/weather + else + echo -e "${wttr}" > /tmp/weather + fi +} + +weather diff --git a/cron/var/spool/cron/pyratebeard b/cron/var/spool/cron/pyratebeard @@ -0,0 +1,27 @@ +# keep an eye on external ip for vpn +*/30 * * * * $HOME/bin/checkip + +# daily backup of specified items +0 4 * * * $HOME/bin/daily_backup + +# check email every hour and notify. full sync daily +0 * * * * $HOME/bin/mail_sync +0 1 * * * offlineimap + +# update rss a few times a day +0 8 * * * $HOME/bin/boat_sync +0 11 * * * $HOME/bin/boat_sync +0 14 * * * $HOME/bin/boat_sync + +# change bg every hour +#0 * * * * $HOME/bin/bgchange + +# check weather twice a day +0 8 * * * $HOME/bin/weather +0 14 * * * $HOME/bin/weather + +# download latest powerzone show +0 8 * * fri $HOME/bin/powerdl + +# weekly comic pack download +0 19 * * thu $HOME/tmp/comic_download/comicdl.sh