aboutsummaryrefslogtreecommitdiff
path: root/bin/update-everything.sh
blob: 403404963518c15aba7ea80734cd5c0802a0b034 (plain)
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
#!/usr/bin/env bash
#
# Author: Clyhtsuriva


# FUNCTIONS
#
# printf_n_notify
# printf_accross_width
# local_update
# remote_update
# non_free_update
# pip_update
# update_scripts_repo


# Print to stdout
# And as a notification
printf_n_notify(){

	printf "%s\n" "[$1]"
	notify-send "[$1]"

}


# Print a line across the entire width of the terminal
printf_accross_width(){

	printf "\n"
	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "$1"
	printf "\n"

}


# Update local xbps packages
# And clean the cache and remove orphans
local_update(){

	printf_n_notify "local update"

	$xi --sync --update --verbose && \
	$xr --clean-cache --remove-orphans --verbose

}


# Update remote debian server using Ansible
remote_update(){

	printf_n_notify "remote update"

	ansible-playbook --inventory-file "$HOME/workbench/ansible/hosts" \
		"$HOME/workbench/ansible/update_adjutor.yml"

}


# Update non-free xbps packages
non_free_update(){

	printf_n_notify "non-free update"

	pushd ~/workbench/auto-void-packages || exit 1
	./update-git-repo.sh
	cd ../void-packages || exit 1
	./xbps-src pkg discord && \
	$xi --repository=hostdir/binpkgs/nonfree discord
	./xbps-src pkg spotify && \
	$xi --repository=hostdir/binpkgs/nonfree spotify
	popd || exit 1

}


# Update pip packages needing one
pip_update(){

	printf_n_notify "pip update"

	python3 -m pip list --outdated --format=json | \
	jq -r '.[] | "\(.name)==\(.latest_version)"' | \
	xargs -n1 pip3 install -U

}


# Execute update-script-repo.sh
# to add, commit and push
# updates of my custom scripts
# and ansible playbooks
update_scripts_repo(){
	printf_n_notify "custom scripts repo update"

	update-scripts-repo.sh

}

update_whatis_db(){
	printf_n_notify "update whatis db"
	makewhatis /usr/share/man
}


# MAIN

xi='sudo xbps-install'
xr='sudo xbps-remove'

printf_n_notify ">>> Global Update >>>"

local_update
printf_accross_width "%"
remote_update
printf_accross_width "%"
non_free_update
printf_accross_width "%"
#pip_update # 2023/01/09 : currently not a stable solution to update pip packages
printf_accross_width "%"
update_scripts_repo
printf_accross_width "%"
update_whatis_db

printf_n_notify "<<< Global Update <<<"