From f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 20 Sep 2017 21:19:05 +0200 Subject: Commit current state --- ops/cynerd_account | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 ops/cynerd_account (limited to 'ops/cynerd_account') diff --git a/ops/cynerd_account b/ops/cynerd_account new file mode 100644 index 0000000..941ff66 --- /dev/null +++ b/ops/cynerd_account @@ -0,0 +1,65 @@ +# vim:ft=sh:noexpandtab +# My personal account + +# Configuration options: +# CYNERD_ACCOUNT_GROUPS - Additional groups to default cynerd,wheel +# CYNERD_ACCOUNT_SSH_KEY - ssh public key to be added as authorized_keys +# CYNERD_ACCOUNT_CONFIGS - myconfigs branch (currently accepting only server) + +. tools/grusr +. tools/package +. tools/git + +CYNERD_ACCOUNT_ARGS="" +CYNERD_ACCOUNT_MYCNF_GIT="" + +cynerd_account_check() { + package_check zsh || CYNERD_ACCOUNT_NEED="zsh" + user_check $CYNERD_ACCOUNT_ARGS || CYNERD_ACCOUNT_NEED="$CYNERD_ACCOUNT_NEED user" + # TODO check that we have correct ssh key + package_check rsync || CYNERD_ACCOUNT_NEED="$CYNERD_ACCOUNT_NEED rsync" + git_check $CYNERD_ACCOUNT_MYCNF_GIT || CYNERD_ACCOUNT_NEED="$CYNERD_ACCOUNT_NEED myconfigs" + if [ -n "$CYNERD_ACCOUNT_NEED" ]; then + echo_info "Cynerd account requires update of these components: $CYNERD_ACCOUNT_NEED" + return 1 + fi +} + +cynerd_account_prepare() { + for N in $CYNERD_ACCOUNT_NEED; do + case "$N" in + zsh|rsync) + package_prepare "$N" || return 1 + ;; + user) + user_prepare $CYNERD_ACCOUNT_ARGS || return 1 + ;; + myconfigs) + git_prepare $CYNERD_ACCOUNT_MYCNF_GIT || return 1 + ;; + esac + done +} + +cynerd_account_apply() { + for N in $CYNERD_ACCOUNT_NEED; do + case "$N" in + zsh|rsync) + package_apply "$N" || return 1 + ;; + user) + user_apply $CYNERD_ACCOUNT_ARGS || return 1 + ;; + myconfigs) + git_apply $CYNERD_ACCOUNT_MYCNF_GIT || return 1 + ;; + esac + done +} + +cynerd_account_clean() { + local FAIL=0 + package_clean zsh rsync || FAIL=1 + git_clean $CYNERD_ACCOUNT_MYCNF_GIT || FAIL=1 + return $FAIL +} -- cgit v1.2.3