-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaintain.sh
More file actions
executable file
·108 lines (86 loc) · 3.17 KB
/
maintain.sh
File metadata and controls
executable file
·108 lines (86 loc) · 3.17 KB
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
#!/usr/bin/env zsh
#===============================================================================
#
# FILE: maintain.sh
# USAGE: ./maintain.sh
# AUTHOR: kcrt <kcrt@kcrt.net>
# COMPANY: Nanoseconds Hunter "http://www.kcrt.net"
#
#===============================================================================
source ${DOTFILES}/script/OSNotify.sh
autoload zmv
case $HOST in
aluminum.local)
if [[ "`networksetup -getairportnetwork en0`" =~ nano* ]]; then
;
else
OSError "Please execute this script at home (or use '-f')."
if [[ "$1" != "-f" ]];then
exit
fi
fi
. "${DOTFILES}/routine/macos_brew_upgrade.sh"
. "${DOTFILES}/routine/generic_clamscan_update_and_scan.sh"
# Before sending server, find Cargo.toml and execute cargo clean
OSNotify "Cleaning up Rust projects..."
cd ~/prog
find . -name Cargo.toml -execdir cargo clean \;
cd ~
if [[ -d /Volumes/Backup/ ]]; then
OSNotify "/Volumes/Backup/ mounted, refreshing QnapFileList.txt..."
pv /Volumes/Backup/QnapFileList.txt | grep -v "AppleDouble" | grep -v "\._" | grep -v "DS_Store" | grep -v ".@__thumb" | LANG=C sort > ~/QnapFileList.txt
else
OSError "/Volumes/Backup not found."
fi
echo_info "==== Data back up and sync ===="
. "${DOTFILES}/routine/aluminum_backup.sh"
echo_info "==== recording (if available) ===="
. "${DOTFILES}/routine/aluminum_recording.sh"
echo_info "==== keepass ===="
cp ~/Documents/passwords.kdbx ~/others/passwords.kdbx
cp ~/Documents/passwords.kdbx "/Users/kcrt/Library/Mobile Documents/iCloud~be~kyuran~kypass2/Documents/passwords.kdbx"
gsutil cp ~/Documents/passwords.kdbx gs://auto.backup.kcrt.net/auto/passwords.kdbx
if [[ -e /Volumes/Backup/ ]]; then
DATE=`date +%Y%m%d`
cp ~/Documents/passwords.kdbx /Volumes/Backup/passwords/passwords-$DATE.kdbx
fi
OSNotify "Cleaning Caches..."
hdfreebefore=`df -h / | grep / | awk '{print $4}'`
cd ~
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport/*
rm -rf ~/Library/Developer/Xcode/Archives/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
rm -rf ~/Library/Developer/CoreSimulator/Caches/dyld/*
xcrun simctl delete unavailable
brew autoremove
brew cleanup -s --prune=1
rm -rf /Users/kcrt/Library/Caches/Cypress/*
npx playwright uninstall all
hdfreeafter=`df -h / | grep / | awk '{print $4}'`
nix-collect-garbage -d && nix-store --optimise
pip3 cache purge
OSNotify "Cleaned. Free space: $hdfreebefore -> $hdfreeafter"
# echo_info "==== joplin ===="
# joplin sync
# echo_info "==== listing data on server ===="
# gsutil ls -R gs://backup.kcrt.net/ | tee ~/gs_backup.txt
;;
*)
echo_error "$HOST is unknown host!"
esac
echo_info "vim update"
vim -c "PluginInstall!" -c "qall"
. "${DOTFILES}/routine/generic_r_install_packages.sh"
echo_info "Google cloud command update"
if [ -x `which gcloud` ]; then
yes | gcloud components update
fi
pip3 install -U crcmod # for gsutil rsync
echo_info "GitHub Copilot update"
if [ -x `which gh` ]; then
gh extension upgrade gh-copilot
fi
echo_info "google key"
wget "https://pki.goog/roots.pem" -O ~/secrets/google-roots.pem
echo_info "FINISHED!"