aboutsummaryrefslogtreecommitdiff
path: root/ops/cynerd_account
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-09-20 21:19:05 +0200
committerKarel Kočí <cynerd@email.cz>2017-09-20 21:22:36 +0200
commitf287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8 (patch)
tree5025b33a8c3d4c69ad2b62e1169b669c56f712f9 /ops/cynerd_account
parent65f52ead41dc6df73671ddd3a8c6a2edecb6dfb3 (diff)
downloadmulticonfig-complicated.tar.gz
multiconfig-complicated.tar.bz2
multiconfig-complicated.zip
Commit current statecomplicated
Diffstat (limited to 'ops/cynerd_account')
-rw-r--r--ops/cynerd_account65
1 files changed, 65 insertions, 0 deletions
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
+}