Failsafe if something is missing

This commit is contained in:
Keith Irwin 2024-07-21 19:27:30 -06:00
parent 6f2e9898a0
commit ab1588b1fa
Signed by: ki9
GPG Key ID: DF773B3F4A88DA86
4 changed files with 20 additions and 4 deletions

View File

@ -9,8 +9,6 @@ mkdir -p ~/.local/src
cd ~/.local/src
git clone https://gitea.gf4.pw/ki9/mktodo.git
cd mktodo
cp env.sample env
${EDITOR} env
cp systemd/* ~/.config/systemd/user/
systemctl --user enable --now mktodo.timer mktodo.service
systemctl --user status mktodo.service

2
daily.sample.md Normal file
View File

@ -0,0 +1,2 @@
[ ] This is something that should be done every day
[ ] This is another task

19
mktodo
View File

@ -1,10 +1,25 @@
#!/bin/bash -u
# mktodo
# Script to refresh todo lists
source ./env
umask 027
# Get env vars
if ! [ -f "./env" ]; then
cp "./env.sample" "./env" || exit 1
fi
source ./env
# Check for required directories and files
if ! [ -d "${NOTES_DIR}" ]; then
mkdir "${NOTES_DIR}" || exit 2
fi
if ! [ -d "${DAILY_TEMPLATE}" ]; then
cp "./daily.sample.md" "${DAILY_TEMPLATE}" || exit 3
fi
if ! [ -d "${MONTHLY_TEMPLATE}" ]; then
cp "./monthly.sample.md" "${MONTHLY_TEMPLATE}" || exit 4
fi
# Create missing lists up to one month from today
for num_days in {01..30}; do
next_date="$(date -I --date=${num_days}days)"

1
monthly.sample.md Normal file
View File

@ -0,0 +1 @@
[ ] This is something that should be done every month