mirror of
				https://github.com/limosek/zaf.git
				synced 2025-10-31 09:37:37 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			101 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			101 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/sh
 | |
| 
 | |
| ZAF_CFG_FILE="/etc/zaf.conf"
 | |
| if [ -f $ZAF_CFG_FILE ]; then
 | |
| 	. $ZAF_CFG_FILE
 | |
| else
 | |
| 	echo "Missing config file $ZAF_CFG_FILE! Exiting."
 | |
| 	exit 2
 | |
| fi
 | |
| [ -d $(dirname $0)/.git ] && ZAF_LIB_DIR=$(dirname $0)/lib
 | |
| 
 | |
| [ -z "$ZAF_TMP_BASE" ] && ZAF_TMP_BASE=/tmp/zaf
 | |
| ZAF_TMP_DIR="${ZAF_TMP_BASE}-${USER}-$$"
 | |
| trap "rm -rif ${ZAF_TMP_DIR}" EXIT
 | |
| ! [ -d "${ZAF_TMP_DIR}" ] && mkdir "${ZAF_TMP_DIR}"
 | |
| [ -z "$ZAF_DEBUG" ] && ZAF_DEBUG=0
 | |
| 
 | |
| . ${ZAF_LIB_DIR}/zaf.lib.sh
 | |
| . ${ZAF_LIB_DIR}/os.lib.sh
 | |
| . ${ZAF_LIB_DIR}/ctrl.lib.sh
 | |
| [ -f ${ZAF_LIB_DIR}/zaf.${ZAF_OS}.sh ] && . ${ZAF_LIB_DIR}/zaf.${ZAF_OS}.sh
 | |
| 
 | |
| case $1 in
 | |
| 
 | |
| check-agent-config)
 | |
| 	zaf_check_agent_config
 | |
| 	;;
 | |
| 
 | |
| update)
 | |
| 	zaf_update_repo
 | |
| 	;;
 | |
| 
 | |
| show)
 | |
| 	if [ -z "$2" ]; then
 | |
| 		zaf_show_installed_plugins
 | |
| 	else
 | |
| 		zaf_show_plugin "$2"
 | |
| 	fi
 | |
| 	;;
 | |
| 
 | |
| list)
 | |
| 	zaf_list_plugins
 | |
| 	;;
 | |
| 
 | |
| list-items)
 | |
| 	if [ -z "$2" ]; then
 | |
| 		zaf_list_items
 | |
| 	else
 | |
| 		zaf_list_plugin_items "$2"
 | |
| 	fi
 | |
| 	;;
 | |
| 
 | |
| test-items)
 | |
| 	zaf_show_plugin "$2" tst
 | |
| 	;;
 | |
| 
 | |
| install)
 | |
| 	shift;
 | |
| 	[ -z "$@" ] && echo "$0 install plugin [plugin]..."
 | |
| 	for p in $@; do
 | |
| 		zaf_install_plugin "$p"
 | |
| 	done
 | |
| 	;;
 | |
| 
 | |
| remove)
 | |
| 	zaf_remove_plugin "$2"
 | |
| 	;;
 | |
| 
 | |
| self-upgrade)
 | |
| 	rm -rf /tmp/zaf-installer && mkdir /tmp/zaf-installer
 | |
| 	if zaf_fetch_url https://raw.githubusercontent.com/limosek/zaf/master/install.sh >/tmp/zaf-installer/install.sh; then
 | |
| 		cd /tmp/zaf-installer && ./install.sh
 | |
| 	else
 | |
| 		echo "Cannot fetch uri https://raw.githubusercontent.com/limosek/zaf/master/install.sh!"; 
 | |
| 	fi
 | |
| 	;;
 | |
| 	
 | |
| self-remove)
 | |
| 	if [ "$2" = "force" ]; then  
 | |
| 	  rm -rf /etc/zaf.conf ${ZAF_PLUGINS_DIR} ${ZAF_REPO_DIR} ${ZAF_LIB_DIR} /usr/bin/zaf ${ZAF_AGENT_CONFIGD}/zaf_*
 | |
| 	else
 | |
| 	  echo "This will remove zaf from this computer and erase all configuration."
 | |
| 	  echo "To continue, please do $0 self-remove force"
 | |
| 	fi
 | |
|       ;;
 | |
| 
 | |
| *)
 | |
| 	echo "$0 update			To update repo" 
 | |
| 	echo "$0 list			To list installed plugins"
 | |
| 	echo "$0 show [plugin]		To show installed plugins or plugin info"
 | |
| 	echo "$0 list-items [plugin]	To list all suported items [for plugin]"
 | |
| 	echo "$0 test-items plugin	To test all suported items for plugin"
 | |
| 	echo "$0 install plugin		To install plugin"
 | |
| 	echo "$0 remove plugin		To remove plugin" 
 | |
| 	echo "$0 self-upgrade		To self-upgrade zaf"
 | |
| 	echo "$0 self-remove		To self-remove zaf and its config"
 | |
| 	;;
 | |
| 
 | |
| esac
 | |
| 
 | 
