switched to roles

- all tasks/* have been moved to their own roles in roles/*
- each file && template is now oragnized per-role
- annotated each task which still isn't idempotent !TODO!
This commit is contained in:
2023-01-14 17:26:17 -06:00
parent d435ab80ac
commit abaa4c9639
23 changed files with 33 additions and 24 deletions

View File

@@ -0,0 +1,26 @@
#!/bin/bash
# This is meant to be run by cron, just setup a cronjob to run this script every day or so
# This script checks if a file ($fileSwitch) is last modified > $dayLimit days ago & if so a script is run
# On your computer or laptop, setup a cronjob to run an ssh command to modify $fileSwitch every couple hours or so.
fileTrigger="$HOME/.deadtrigger"
fileLock="$HOME/.deadlock" # if this file exists, the deadmans switch will be disabled. This file is automatically created when the switch is pulled
scriptToRun="$HOME/deadman/imdead.sh"
dayLimit=14 # 14 day trigger
# if our file lock exists, we already ran OR the switch has been disabled on purpose
if [ -f "$fileLock" ]; then
exit 0
fi
# time has to be in seconds so dayLimit (days) * 24 (hours in a day) * 60 (mins in an hour) * 60 (seconds in a min)
let "triggerTime=$dayLimit * 24 * 60 * 60"
let "lastPing=$(stat -c %Y $fileTrigger)"
let "currTime=$(date +%s)"
let "dTime=$currTime-$lastPing"
echo $dTime
if [ $dTime -gt $triggerTime ]
then
touch $fileLock
bash $scriptToRun
fi

View File

@@ -0,0 +1,18 @@
#!/bin/bash
cd $HOME/deadman
postPatch='dead.patch'
pageName='content/pages/dead.md'
currDate=$(date '+%Y-%m-%d')
git clone git@github.com:CPunch/openpunk.git
# commit & push the post
cd openpunk
git am postPatch
# replace our --DATE-- with the current date
sed -i 's/--DATE--/'$currDate'/g' $pageName
git add .
git commit -m "DeadSwitch: No response from CPunch in 14 days, posting dead.md"
git push --force

View File

@@ -0,0 +1,37 @@
---
- name: Create deadman directory
file:
name: /root/deadman
state: directory
- name: Install deadswitch script
copy:
src: deadswitch
dest: /usr/local/bin/deadswitch
mode: u+rx
- name: Install imdead.sh
copy:
src: imdead.sh
dest: /root/deadman/imdead.sh
mode: u+rx
- name: Copy dead patch
copy:
src: secrets/dead.patch
dest: /root/deadman/dead.patch
mode: u+rw
# TODO: make idempotent
- name: Install deadtrigger
file:
name: /root/.deadtrigger
state: touch
# Run deadswitch daily at 1am
- name: Install deadlock cronjob
cron:
name: Run deadswitch
minute: 0
hour: 1
job: /usr/local/bin/deadswitch