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


# FUNCTIONS
#
# echo_n_notify
# local_update
# remote_update
# non_free_update
# pip_update


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

# Print to stdout
# And as a notification
echo_n_notify(){
	printf "%s\n" "[$1]"
	notify-send "[$1]"
}

echo_n_notify "Updating everything ..."

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

	echo_n_notify "local update"

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

}

# Update remote debian server using Ansible
remote_update(){

	echo_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(){

	echo_n_notify "non-free update"

	pushd ~/workbench/auto-void-packages || exit 1
	./update-git-repo.sh
	cd ../void-packages || exit 1
	./xbps-src pkg teams-bin && \
	$xi --repository=hostdir/binpkgs/nonfree teams-bin
	./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(){

	echo_n_notify "pip update"

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

}


# MAIN

local_update
remote_update
non_free_update
pip_update