mirror of
https://github.com/CPunch/openpunk-ansible.git
synced 2024-11-22 15:30:05 +00:00
Added blog cron job, setup zsh & powerlevel10k theme
This commit is contained in:
parent
05943624b9
commit
e795959672
@ -1,4 +1,4 @@
|
|||||||
# Openpunk's ansible recovery
|
# OpenPunk's ansible recovery
|
||||||
|
|
||||||
This is my failsafe (and also my helpful migration tool) for restoring the OpenPunk server. This handles setting everything back up, including:
|
This is my failsafe (and also my helpful migration tool) for restoring the OpenPunk server. This handles setting everything back up, including:
|
||||||
|
|
||||||
|
@ -3,9 +3,26 @@
|
|||||||
repo: "https://github.com/CPunch/openpunk.git"
|
repo: "https://github.com/CPunch/openpunk.git"
|
||||||
dest: "/var/www/{{ domain }}"
|
dest: "/var/www/{{ domain }}"
|
||||||
|
|
||||||
|
- name: Setup git config
|
||||||
|
copy:
|
||||||
|
src: templates/.gitconfig
|
||||||
|
dest: /root/.gitconfig
|
||||||
|
owner: root
|
||||||
|
mode: u=rw,g=,o=
|
||||||
|
|
||||||
- name: Build blog
|
- name: Build blog
|
||||||
command:
|
command:
|
||||||
cmd: hugo
|
cmd: hugo
|
||||||
chdir: "/var/www/{{ domain }}"
|
chdir: "/var/www/{{ domain }}"
|
||||||
|
|
||||||
# TODO: missing cron job for regenerating the static blog every hour
|
- name: Install updateBlog script
|
||||||
|
template:
|
||||||
|
src: templates/blog/updateBlog
|
||||||
|
dest: /usr/local/bin/updateBlog
|
||||||
|
mode: u+rwx
|
||||||
|
|
||||||
|
- name: Setup blog cron job
|
||||||
|
cron:
|
||||||
|
name: Build blog every hour
|
||||||
|
minute: 0
|
||||||
|
job: /usr/local/bin/updateBlog
|
0
tasks/deadswitch.yml
Normal file
0
tasks/deadswitch.yml
Normal file
@ -25,4 +25,14 @@
|
|||||||
- tor
|
- tor
|
||||||
- ufw
|
- ufw
|
||||||
- htop
|
- htop
|
||||||
|
- zsh # :D
|
||||||
- python3-certbot-nginx
|
- python3-certbot-nginx
|
||||||
|
|
||||||
|
- name: Setup default shell (zsh)
|
||||||
|
shell: chsh -s /usr/bin/zsh
|
||||||
|
|
||||||
|
- name: Clone Powerlevel10k theme
|
||||||
|
shell: git clone --depth=1 https://github.com/romkatv/powerlevel10k.git /root/powerlevel10k
|
||||||
|
|
||||||
|
- name: Install Powerlevel10k theme
|
||||||
|
shell: echo 'source /root/powerlevel10k/powerlevel10k.zsh-theme' > /root/.zshrc
|
@ -1,9 +1,13 @@
|
|||||||
- name: Configure Gitea
|
- name: Configure Gitea
|
||||||
become: yes
|
|
||||||
become_user: gitea
|
|
||||||
template:
|
template:
|
||||||
src: templates/gitea/app.ini
|
src: templates/gitea/app.ini
|
||||||
dest: /etc/gitea/app.ini
|
dest: /etc/gitea/app.ini
|
||||||
|
owner: gitea
|
||||||
|
|
||||||
|
- name: Setup Gitea database
|
||||||
|
become: yes
|
||||||
|
become_user: gitea
|
||||||
|
shell: gitea migrate -c /etc/gitea/app.ini
|
||||||
|
|
||||||
- name: Reload Gitea
|
- name: Reload Gitea
|
||||||
systemd:
|
systemd:
|
||||||
|
7
templates/.gitconfig
Normal file
7
templates/.gitconfig
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[user]
|
||||||
|
email = openpunk@proton.me
|
||||||
|
name = OpenPunk
|
||||||
|
[core]
|
||||||
|
editor = nano
|
||||||
|
[pull]
|
||||||
|
rebase = true
|
26
templates/blog/deadswitch
Normal file
26
templates/blog/deadswitch
Normal 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
|
19
templates/blog/imdead.sh
Normal file
19
templates/blog/imdead.sh
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cd $HOME/deadman
|
||||||
|
|
||||||
|
postTemplate='dead.md'
|
||||||
|
pageName='openpunk/content/pages/dead.md'
|
||||||
|
currDate=$(date '+%Y-%m-%d')
|
||||||
|
|
||||||
|
git clone git@github.com:CPunch/openpunk.git
|
||||||
|
cp $postTemplate $pageName
|
||||||
|
|
||||||
|
# replace our {{DATE}} with the current date
|
||||||
|
sed -i 's/{{DATE}}/'$currDate'/g' $pageName
|
||||||
|
|
||||||
|
# commit & push the post
|
||||||
|
cd openpunk
|
||||||
|
git add .
|
||||||
|
git commit -m "DeadSwitch: Posted dead message"
|
||||||
|
git push
|
5
templates/blog/updateBlog
Normal file
5
templates/blog/updateBlog
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd /var/www/{{ domain }}
|
||||||
|
/usr/bin/git fetch origin
|
||||||
|
/usr/bin/git reset --hard origin/main
|
||||||
|
/usr/bin/hugo
|
@ -2,6 +2,16 @@ APP_NAME = OpenPunk Gitea
|
|||||||
RUN_USER = gitea
|
RUN_USER = gitea
|
||||||
RUN_MODE = prod
|
RUN_MODE = prod
|
||||||
|
|
||||||
|
[database]
|
||||||
|
DB_TYPE = sqlite3
|
||||||
|
HOST = 127.0.0.1:5432
|
||||||
|
NAME = gitea
|
||||||
|
USER = gitea
|
||||||
|
PASSWD =
|
||||||
|
SSL_MODE = disable
|
||||||
|
CHARSET = utf8
|
||||||
|
PATH = /var/lib/gitea/data/gitea.db
|
||||||
|
|
||||||
[repository]
|
[repository]
|
||||||
ROOT = /var/lib/gitea/gitea-repositories
|
ROOT = /var/lib/gitea/gitea-repositories
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user