aboutsummaryrefslogtreecommitdiff
path: root/ops/cynerd_account
diff options
context:
space:
mode:
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
+}