[
{
	"service": "vpn",
	"type": "np",
	"description": "Setup VPN for np",
	"steps" :
	[
		"sudo openvpn --config work/local/ops-nonlive.ovpn"
	]
},
{
	"service": "vpn",
	"type": "pr",
	"description": "Setup VPN for pr",
	"steps" :
	[
		"echo sudo openvpn --config work/local/ops-live.ovpn"
	]
},
{
	"service": "vpn",
	"type": "Ten10",
	"description": "Setup VPN for Ten10",
	"steps" :
	[
		"sudo openvpn --config work/local/Ten10_theodore.zacharia_remote.ten10.com.ovpn"
	]
},
{
	"service": "vpn",
	"type": "test",
	"description": "Test VPN connection for ops",
	"steps" :
	[
		"curl -s https://vpnendpoint/ | sed -E 's/<[^>]*>//g'"
	]
},
{
	"service": "vpn",
	"type": "proton",
	"description": "Setup VPN for Proton",
	"steps" :
	[
		"VPNLIST='jp-free-01.protonvpn.net.udp.ovpn nl-free-01.protonvpn.net.udp.ovpn us-free-01.protonvpn.net.udp.ovpn'",
		"VPNRND=$[ $RANDOM % 3 + 1 ]",
		"VPNCFG=$(echo $VPNLIST | cut -d' ' -f $VPNRND)",
		"echo Using ProtonVPN: $VPNCFG",
		"sudo openvpn --config work/ddrive/PDrive/ProtonVPN/$VPNCFG"
	]
},
{
	"service": "lan",
	"type": "",
	"description": "Setup mount point for network drive, Setting up LAN with optional filter for drives, use names from mounts.lsetup.conf",
	"steps" :
	[
		"./mlan.lsetup.sh mounts.lsetup.conf $2",
		"echo \"Mounting completed at $(date)\"",
		"ffplay -nodisp -t 1 -autoexit ~/work/ddrive/userdata/sounds/notifications/access-granted-voice-ringtone.mp3 2>/dev/null"
	]
},
{
	"service": "home",
	"type": "t",
	"description": "Open preconfigured terminal windows for home operations, to capture use: mate-terminal --save-config myconfig.test.conf",
	"steps" :
	[
		"mate-terminal --load-config=mateterm.lsetup.conf"
	]
},
{
	"service": "home",
	"type": "apps",
	"description": "Run all the home apps",
	"steps" :
	[
		"if test $(uname -n) = PegasusM20 ; then ./lsetup.sh home t ; fi",
		"sleep 1",
		"if ! pgrep firefox >/dev/null ; then firefox ; sleep 2 ; fi &",
		"sleep 2",
		"if ! pgrep thunderbird >/dev/null ; then thunderbird ; sleep 2 ; fi &",
		"sleep 2",
		"if ! pgrep vscode >/dev/null ; then APGM=$(which code) ; if [ -n \"$APGM\" ] ; then code ; else /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=code --file-forwarding com.visualstudio.code --reuse-window @@ @@ ; fi ; sleep 2 ; fi & ",
		"if ! pgrep cherrytree >/dev/null ; then /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=cherrytree --file-forwarding com.giuspen.cherrytree 2>/dev/null ; sleep 1 ; fi &",
		"echo \"Home Apps Started at $(date)\""
	]
},
{
	"service": "work",
	"type": "apps",
	"description": "Run all the work apps",
	"steps" :
	[
		"if test $(uname -n) = PegasusM20 ; then ./lsetup.sh work tl ; fi",
		"if ! pgrep upm.sh >/dev/null ; then ~/tools/upm-1.15.1/upm.sh ~/work/ddrive/PDrive/iptpass ; sleep 1 ; fi &",
		"sleep 5",
		"wmctrl -r \"Universal Password Manager\" -e 0,8,399,322,275",
		"if ! ps aux | grep chrome | grep -v slack | grep -v grep >/dev/null ; then /usr/bin/google-chrome-stable \"--profile-directory=Default\" %U >/dev/null 2>/dev/null ; sleep 1 ; fi &",
		"sleep 2",
		"if ! pgrep slack >/dev/null ; then if which slack >/dev/null ; then /usr/bin/slack %U >/dev/null 2>/dev/null ; sleep 1 ; else /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=slack --file-forwarding com.slack.Slack @@u %U @@ ; sleep 1  ; fi ; fi &",
		"sleep 2",
		"if ! pgrep zim >/dev/null ; then /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=zim --file-forwarding org.zim_wiki.Zim 2>/dev/null ; sleep 1 ; fi &",
		"if ! pgrep sublime >/dev/null ; then /opt/sublime_text/sublime_text 2>/dev/null ; sleep 1 ; fi &",
		"sleep 2",
		"echo \"Work Apps Started at $(date)\""
	]
},
{
	"service": "work",
	"type": "t",
	"description": "Open preconfigured terminator windows for work operations on tpmem01",
	"steps" :
	[
		"if ! pgrep terminator >/dev/null || [ $FORCEIT -eq 1 ] ; then /usr/bin/terminator -g ~/work/ddrive/userdata/terminator/tpmem01 -T tpmem01 >/dev/null 2>/dev/null ; sleep 3 ; else echo 'Already running, use -f to force start' ; fi &"
	]
},
{
	"service": "work",
	"type": "t2",
	"description": "Open preconfigured terminator windows for work operations on tpmem02",
	"steps" :
	[
		"if ! pgrep terminator >/dev/null || [ $FORCEIT -eq 1 ] ; then /usr/bin/terminator -g ~/work/ddrive/userdata/terminator/tpmem02 -T tpmem02 >/dev/null 2>/dev/null ; sleep 3 ; else echo 'Already running, use -f to force start' ; fi &"
	]
},
{
	"service": "work",
	"type": "tl",
	"description": "Open preconfigured terminal windows for home operations, to capture use: mate-terminal --save-config myconfig.test.conf",
	"steps" :
	[
		"mate-terminal --load-config=mateterm.workl.lsetup.conf"
	]
},
{
	"service": "vnc",
	"type": "",
	"description": "Start xvnc services for sharing the Desktop",
	"steps" :
	[
		"sudo systemctl start x11vnc.service"
	]
},
{
	"service": "smb",
	"type": "",
	"description": "Start samba services for sharing disks with Windows",
	"steps" :
	[
		"sudo touch /etc/libuser.conf",
		"sudo system-config-samba &"
	]
},
{
	"service": "syncme",
	"type": "",
	"description": "Syncing this script and files to a local share/backup",
	"steps" :
	[
		"cp mounts.lsetup.conf ./work/home/shell/machine_setup/",
		"cp mateterm.lsetup.conf ./work/home/shell/machine_setup/",
		"cp mateterm.workl.lsetup.conf ./work/home/shell/machine_setup/",
		"cp mlan.lsetup.sh ./work/home/shell/machine_setup/",
		"cp lsetup.cfg ./work/home/shell/machine_setup/",
		"cp lsetup.sh ./work/home/shell/machine_setup/",
		"if [ $? -eq 0 ] ; then echo 'lsetup files synced' ; aplay -q ~/work/ddrive/userdata/sounds/notifications/mixkit-confirmation-tone-2867.wav ; else echo 'failed to sync lsetup files' ; fi "
	]
},
{
	"service": "ytup",
	"type": "",
	"description": "Updates youtube-dl, the youtube downloader",
	"steps" :
	[
		"sudo youtube-dl -U"
	]
},
{
	"service": "YTDL",
	"type": "",
	"description": "Downloads youtube-dl, the youtube downloader",
	"steps" :
	[
		"sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/bin/youtube-dl",
		"sudo chmod a+rx /usr/bin/youtube-dl"
	]
},
{
	"service": "res",
	"type": "",
	"description": "Set the screen resolution",
	"steps" :
	[
		"./lsetup.sh res $(uname -n)"
	]
},
{
	"service": "res",
	"type": "Leviathan",
	"description": "Set the screen resolution",
	"steps" :
	[
		"xrandr --output DVI-I-2 --set underscan on --set \"underscan vborder\" 30 --set \"underscan hborder\" 30"
	]
},
{
	"service": "res",
	"type": "ViperM19",
	"description": "Set the screen resolution",
	"steps" :
	[
		"xrandr --newmode \"1680x1050_60.00\"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync",
		"xrandr --addmode \"1680x1050_60.00\"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync",
		"xrandr --addmode HDMI-1 1680x1050_60.00",
		"xrandr --output HDMI-1 --mode \"1680x1050_60.00\""
	]
},
{
	"service": "res",
	"type": "AtlantaM20",
	"description": "Set the screen resolution, can use: \"./lsetup.sh res $(uname -n)\"",
	"steps" :
	[
		"xrandr --newmode \"1920x1080_60.00\"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync",
		"xrandr --addmode DVI-0 \"1920x1080_60.00\"",
		"xrandr --output DVI-0 --mode \"1920x1080_60.00\""
	]
},
{
	"service": "res",
	"type": "TiddyM",
	"description": "Set the screen resolution, can use: \"./lsetup.sh res $(uname -n)\"",
	"steps" :
	[
		"xrandr --newmode \"1680x1050_60.00\"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync",
		"xrandr --addmode VGA-1 \"1680x1050_60.00\"",
		"xrandr --output VGA-1 --mode \"1680x1050_60.00\""
	]
},
{
	"service": "kc",
	"type": "",
	"description": "Quickly kill any hanging chrome instances, currently kills something else, so beware !",
	"steps" :
	[
		"for A in `ps -ef | grep field | grep chrome | awk '{print $2},'`; do kill -9 $A;done"
	]
},
{
	"service": "wakeup",
	"type": "Cerberus",
	"description": "Send wakeonlan message to Cerberus",
	"steps" :
	[
		"wakeonlan ma:ca:dd:re:ss:zz"
	]
},
{
	"service": "wakeup",
	"type": "Galactica",
	"description": "Send wakeonlan message to Galactica",
	"steps" :
	[
		"wakeonlan ma:ca:dd:re:ss:zz"
	]
},
{
	"service": "wakeup",
	"type": "Deepstar5",
	"description": "Send wakeonlan message to Deepstar5",
	"steps" :
	[
		"wakeonlan ma:ca:dd:re:ss:zz"
	]
},
{
	"service": "mfa",
	"type": "list",
	"description": "list the keys which can be used for mfa",
	"steps" :
	[
        "gpg -d ~/work/home/ipt/env/gauth-export.json.gpg | jq -r ' .[].name '"
	]
},
{
	"service": "mfa",
	"type": "all",
	"description": "Call oathtool to get MFA/2FA code using export from GAuth json file, get for ALL defined keys",
	"steps" :
	[
        "shift 1; VO='\"'$@'\"' ",
        "T1=$$.tmp ; gpg -d ~/work/home/ipt/env/gauth-export.json.gpg | jq -r ' .[].name ' > $T1",
		"while read TKEY ; do echo \"$TKEY ----\" ; sh lsetup.sh mfa $TKEY ; done<$T1 ; rm -f $T1"
	]
},
{
	"service": "mfa",
	"type": "",
	"description": "Call oathtool to get MFA/2FA code using export from GAuth json file, use the mfa name as the argument",
	"steps" :
	[
        "shift 1; VO='\"'$@'\"' ",
        "T1=$$.tmp ; gpg -d ~/work/home/ipt/env/gauth-export.json.gpg 2>/dev/null | jq -r ' .[] | select( .[\"name\"] | contains('\"$VO\"') ).secret ' > $T1 ; if [ $(wc -l $T1 | awk '{print $1}') -eq 1 ] ; then  D=$(date  +%S) ; if [ $D -gt 29 ] ; then TTL=`expr 59 - $D` ; else TTL=`expr 29 - $D` ; fi ; printf ' '$TTL' ' ; oathtool -b --totp $(cat $T1) ; else echo 'no unique entry found' ; fi ; rm -f $T1",
        "# can also do printf OATHCODE | xclip -sel clip"
	]
}
]