-
Notifications
You must be signed in to change notification settings - Fork 0
/
housekeeping
executable file
·179 lines (146 loc) · 5.56 KB
/
housekeeping
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/usr/bin/env bash
# A script for unrelated tasks I want to run every so often
# Uses my 'evry' tool to handle how often to run tasks:
# https://github.com/purarue/evry
declare -a wfi_args=()
if [[ -z "$1" ]]; then
wfi_args+=("--quiet")
else
wfi_args+=("$@")
fi
wait-for-internet "${wfi_args[@]}" || exit $?
# make sure commands exist
export HAVECMD_REPORT=1
# approve guestbook comments on https://github.com/purarue/glue
evry 6 hours -approve-comments && approve-comments
# backup cache/tokens/logs from my server
evry 3 days -backup_server && vps_backup_server
# https://github.com/purarue/reminder-sink
evry 1 day -reminders-notify && reminder-sink-notify
evry 1 day -reminder-silence-prune && reminder-sink --debug silence reset --if-expired
evry 1 day -save-sms-images && sms-images
# https://github.com/andreafrancia/trash-cli
evry 1 week -empty-trash && {
dust ~/.local/share/Trash
trash-empty
}
# run https://github.com/odeke-em/drive to pull/push from google drive
evry 6 hours -google-drive && {
# run in subshell to avoid changing directory
(
cd "${HOME}/GoogleDrive/" || exit $?
echo "Syncing Google Drive..."
drive pull -ignore-conflict -no-prompt || {
drive pull -fix-clashes -no-prompt && drive pull -no-prompt
}
drive push -no-prompt
# if there's a new google takeout, unzip it
# https://github.com/purarue/google_takeout_parser
# script from https://github.com/purarue/HPI-personal
TAKEOUT_DIR="${HOME}/GoogleDrive/Takeout"
[[ -e "$TAKEOUT_DIR" ]] && unzip-google-takeout "$TAKEOUT_DIR" && drive push
# remove takeout dir (only works if directory is empty)
[[ -e "$TAKEOUT_DIR" ]] && {
rmdir "${TAKEOUT_DIR}"
[[ ! -e "$TAKEOUT_DIR" ]] && drive push
}
)
}
# refresh https://dev.twitch.tv/docs/api/
# so that https://github.com/purarue/twitchlive continues to work
evry 2 months -twitch_cli && twitch token
evry 2 hours -data-sync-conflicts && {
SYNC_CONFLICTS="$(sync-conflicts "$HPIDATA" 2>/dev/null)"
[[ -n "$SYNC_CONFLICTS" ]] && {
echo "Sync conflicts in ~/data:"
echo "$SYNC_CONFLICTS"
}
}
# make sure all my music is mp3s
evry 1 day -check-music-extensions && check-music-extensions
# make sure none of my playlist paths are broken
# https://github.com/purarue/plaintext-playlist
evry 1 day -plainplay-resolve && plainplay resolve
# fix broken ID3 metadata on my music, add songs to my car playlist
# https://github.com/purarue/plaintext_playlist_py
evry 3 weeks -id3stuff && id3stuff -R
evry 1 day -car-playlist && car-playlist
evry 1 day -backup-keepassdb && backup-keepass-db
# check for new formats in normalizing solves into a single schema
# https://github.com/purarue/scramble-history
evry 1 day -check-scramble-history-formats && {
python3 -m scramble_history merge --check
rifleman "$XDG_CONFIG_HOME/scramble_history/sourcemap.json"
}
# update https://github.com/purarue/mnu_gsheets
evry 1 day -mnu && {
ssh vultr './vps/bin/mnu update' && mnu sync
}
if main-machine; then
# make sure my pythonanywhere website doesn't expire:
# https://github.com/purarue/pythonanywhere-3-months
evry 2 months -pythonanywhere && python3 -m pythonanywhere_3_months -c "$(which chromedriver)"
evry 1 day -update-projects && {
(cd "$REPOS/projects" && ./update && git status)
}
evry 1 week -sync-dbsentinel && {
(cd "$REPOS/dbsentinel" && ./scripts/sync_from_remote)
}
# https://github.com/purarue/grouvee_export
evry 2 months -grouvee-export && python3 -m grouvee_export export
# https://github.com/purarue/albums
# try to resolve releases to their collection URLs/refresh expired album data
evry 1 week -discogs-update && {
(cd "$REPOS/albums" && ./update -r)
}
# https://github.com/purarue/HPI-personal/blob/master/scripts/backup-cubing
backup-cubing
# remove redundant backups, merge browser/mpv history
# https://github.com/purarue/bleanser
evry 1 week -merge-browser-history && merge-browser-history
evry 1 week -merge-mpv-history && merge-mpv-history
evry 1 month -dedupe-ghexport && dedupe-ghexport --move-files
# https://github.com/purarue/HPI-personal/blob/master/scripts/mpv_clean_priv_frames
evry 1 day -clean-mpv-priv-frames && {
echo 'Checking priv mpv frames...'
mpv-clean-priv-frames clean
}
# other random private jobs
bash "$HPIDATA/private.job"
BACKUP_FILE="${HOME}/.cache/restic-backup.lastrun"
restic-backup connected >/dev/null 2>&1 && DRIVE_CONNECTED=1 || DRIVE_CONNECTED=0
RUN_BACKUP=0
if [[ ! -e "$BACKUP_FILE" ]]; then
RUN_BACKUP=1
else
# if its been more than 7 days since the last backup, or its been more
# than 5 days and the drive is connected
file-modified-within "$BACKUP_FILE" 7 days 2>/dev/null || RUN_BACKUP=1
fi
if [[ "$RUN_BACKUP" -eq 1 ]] && [[ "$DRIVE_CONNECTED" -eq 1 ]]; then
figlet -f slant "Starting backup..." 2>/dev/null
restic-backup backup
fi
evry 3 days -auto-mal-update && {
auto-mal-update && rm -rvf "$(evry location -malexport_partial_update)"
}
# run malexport update https://github.com/purarue/malexport/
bash "${HPIDATA}/malexport.job"
evry 1 day -malexport_partial_update && {
malexport_partial_update
}
fi
evry 1 day -review-removed-dir && review-removed-dir
# https://github.com/purarue/my_feed
# once a week, re-index to update any scores/metadata I've updated
if evry 1 week -my-feed-re-index; then
FEED_REINDEX=1 "${REPOS}/my_feed/scripts/feed_index"
else
evry 1 day -my-feed-index && "${REPOS}/my_feed/scripts/feed_index"
# evry 6 hours -timezone-has-changed && timezone-has-changed && {
# # shellcheck disable=SC2016
# notify 'Timezone has changed, should run timedatectl set-timezone "$(current-timezone)"'
# }
fi
touch ~/.cache/housekeeping.lastrun
true