summaryrefslogtreecommitdiff
path: root/playbooks.d/user-tyil/playbook.bash
blob: de91595506f9daec84c5f7b18d77af9142eeffcd (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
#!/usr/bin/env bash

playbook_add() {
	notice "$BASHTARD_PLAYBOOK" "Creating user 'tyil'"
	useradd \
		--no-create-home \
		tyil

	notice "$BASHTARD_PLAYBOOK" "Cloning dotfiles"
	git clone "$(config "users.tyil.git.url")" "$(config "users.tyil.home")"
	chown -R tyil:tyil "$(config "users.tyil.home")"

	playbook_sync
}

playbook_sync() {
	local packages=(
		bash
		git
		sudo
		zsh
	)

	notice "$BASHTARD_PLAYBOOK" "Installing all desired utilities"
	for package in "${packages[@]}"
	do
		pkg install "$package"
	done

	[[ $BASHTARD_COMMAND == "add" ]] && return

	notice "$BASHTARD_PLAYBOOK" "Updating dotfiles"
	sudo -u tyil \
		git -C "$(config "users.tyil.home")" pull origin "$(config "users.tyil.git.branch")"
}

playbook_del() {
	userdel tyil
	rm -fr --one-file-system -- "$(config "users.tyil.home")"
}