#!/usr/bin/bash
##==============================================================================
## Copyright (c) 2021-2024 Mattsoft/PoiXson
## <https://mattsoft.net> <https://poixson.com>
## Released under the AGPL 3.0
##
## Description: Installer for Configer service management system
##
## Example:
## > curl --output configer-install.sh https://configer.online/install.sh
## > sh configer-install.sh --wizard
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU Affero General Public License as
## published by the Free Software Foundation, either version 3 of the
## License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU Affero General Public License for more details.
##
## You should have received a copy of the GNU Affero General Public License
## along with this program.  If not, see <https://www.gnu.org/licenses/>.
##==============================================================================
# configer-install.sh
VERSION="0.2.110"

clear
echo



export YES=0
export NO=1

NUM_COLORS=$( tput colors 2>/dev/null )
if [[ $NUM_COLORS == ?(-)+([0-9]) ]] \
&& [[ $NUM_COLORS -ge 8 ]]; then
	COLOR_BLACK='\e[0;30m'
	COLOR_BLUE='\e[0;34m'
	COLOR_GREEN='\e[0;32m'
	COLOR_CYAN='\e[0;36m'
	COLOR_RED='\e[0;31m'
	COLOR_PURPLE='\e[0;35m'
	COLOR_BROWN='\e[0;33m'
	COLOR_LIGHTGRAY='\e[0;37m'
	COLOR_DARKGRAY='\e[1;30m'
	COLOR_LIGHTBLUE='\e[1;34m'
	COLOR_LIGHTGREEN='\e[1;32m'
	COLOR_LIGHTCYAN='\e[1;36m'
	COLOR_LIGHTRED='\e[1;31m'
	COLOR_LIGHTPURPLE='\e[1;35m'
	COLOR_YELLOW='\e[1;33m'
	COLOR_WHITE='\e[1;37m'
	COLOR_RESET='\e[0m'
else
	COLOR_BLACK=''
	COLOR_BLUE=''
	COLOR_GREEN=''
	COLOR_CYAN=''
	COLOR_RED=''
	COLOR_PURPLE=''
	COLOR_BROWN=''
	COLOR_LIGHTGRAY=''
	COLOR_DARKGRAY=''
	COLOR_LIGHTBLUE=''
	COLOR_LIGHTGREEN=''
	COLOR_LIGHTCYAN=''
	COLOR_LIGHTRED=''
	COLOR_LIGHTPURPLE=''
	COLOR_YELLOW=''
	COLOR_WHITE=''
	COLOR_RESET=''
fi



function error_msg() {
	echo "$*" >&2
}
function notice() {
	echo -e "${COLOR_LIGHTCYAN} [NOTICE] ${COLOR_RESET}$*" >&2
}
function warning() {
	echo -e "${COLOR_LIGHTRED} [WARNING] ${COLOR_RESET}$*" >&2
}
function failure() {
	echo -e "${COLOR_RED} [FAILURE] ${COLOR_RESET}$*" >&2
}

function title() {
	LONGEST_LEN=1
	for LINE in "$@"; do
		local LEN=${#LINE}
		if [ $LEN -gt $LONGEST_LEN ]; then
			LONGEST_LEN=$LEN
		fi
	done
	local _A=$(($LONGEST_LEN+8))
	local _B=$(($LONGEST_LEN+2))
	# format C
	for LINE in "${@}"; do
		local _S=$(($_B-${#LINE}))
		echo -ne "${COLOR_BROWN} [ ${LINE}"; eval "printf ' '%.0s {2..$_S}"; echo -e "]${COLOR_RESET}"
	done
}



OS_NAME=$(grep ^ID= "/etc/os-release")
OS_NAME=${OS_NAME#*=}
OS_NAME=${OS_NAME//\"}

OS_VERSION=$(grep ^VERSION_ID= "/etc/os-release")
OS_VERSION=${OS_VERSION#*=}
OS_VERSION=${OS_VERSION//\"}

if [[ -z $OS_NAME ]]; then
	failure "OS type not detected."
	failure ; exit 1
fi
if [[ -z $OS_VERSION ]]; then
	failure "OS version not detected."
	failure ; exit 1
fi



# CentOS / Rocky
if [[ "$OS_NAME" == "centos" ]] || [[ "$OS_NAME" == "rocky" ]]; then
	if   [[ "$OS_VERSION" == "9."* ]]; then
		OS_TITLE="CentOS/Rocky 9"
		REMI_RELEASE_URL="https://rpms.remirepo.net/enterprise/remi-release-9.rpm"
	elif [[ "$OS_VERSION" == "8."* ]]; then
		OS_TITLE="CentOS/Rocky 8"
		REMI_RELEASE_URL="https://rpms.remirepo.net/enterprise/remi-release-8.rpm"
	else
		failure "Unsupported OS version: $OS_NAME $OS_VERSION"
		failure ; exit 1
	fi

# Fedora
elif [[ "$OS_NAME" == "fedora" ]]; then
	if   [[ "$OS_VERSION" == "37" ]]; then
		OS_TITLE="Fedora 37"
		REMI_RELEASE_URL="https://rpms.remirepo.net/fedora/remi-release-37.rpm"
	elif [[ "$OS_VERSION" == "36" ]]; then
		OS_TITLE="Fedora 36"
		REMI_RELEASE_URL="https://rpms.remirepo.net/fedora/remi-release-36.rpm"
	else
		failure "Unsupported OS version: $OS_NAME $OS_VERSION"
		failure ; exit 1
	fi
# unsupported os
else
	failure "Unsupported OS: $OS_NAME $OS_VERSION"
	failure ; exit 1
fi



function DisplayHeader() {
	echo -e " ${COLOR_BLUE}╔═╗┌─┐┌┐┌┌─┐┬┌─┐┌─┐┬─┐ ╦╔═╗${COLOR_RESET} "
	echo -e " ${COLOR_BLUE}║  │ ││││├┤ ││ ┬├┤ ├┬┘ ║║ ║${COLOR_RESET} "
	echo -e " ${COLOR_BLUE}╚═╝└─┘┘└┘└  ┴└─┘└─┘┴└─*╩╚═╝${COLOR_RESET} "
	echo
	if [[ -z $1 ]]; then
		echo " This script will reconfigure your server."
		echo " You should begin with a freshly installed OS."
		echo
	fi
}

function DisplayHelp() {
	DisplayHeader
	echo -e "${COLOR_BROWN}Usage:${COLOR_RESET}"
	echo    "  install.sh [options]"
	echo
	echo -e "${COLOR_BROWN}Packages:${COLOR_RESET}"
#TODO: add more services here
	echo -e "  ${COLOR_GREEN}panel, clerk, dns, web, php, mc, mqtt${COLOR_RESET}"
	echo
	echo -e "${COLOR_BROWN}Options:${COLOR_RESET}"
	echo -e "  ${COLOR_GREEN}-a, --auto${COLOR_RESET}                Auto install packages using info from configer.json"
	echo -e "  ${COLOR_GREEN}-w, --wizard, --ask${COLOR_RESET}       Ask questions before installing"
	echo -e "  ${COLOR_GREEN}-y, --yes${COLOR_RESET}                 Automatically answer yes for all questions"
	echo -e "  ${COLOR_GREEN}-D, --dry${COLOR_RESET}                 Dry-run, no changes will be performed by actions"
	echo -e "  ${COLOR_GREEN}-T, --testing, --dev${COLOR_RESET}      Install development testing builds, the absolute latest versions"
	echo
	echo -e "  ${COLOR_GREEN}-v, --verbose${COLOR_RESET}             Enable debug logs"
	echo -e "  ${COLOR_GREEN}-V, --version${COLOR_RESET}             Display the version"
	echo -e "  ${COLOR_GREEN}-h, --help${COLOR_RESET}                Display this help message and exit"
	echo
	exit 1
}

function DisplayVersion() {
	echo -e "${COLOR_BROWN}Configer Installer${COLOR_RESET} ${COLOR_GREEN}${VERSION}${COLOR_RESET}"
	echo
}



if [[ -z $@ ]]; then
	DisplayHelp
	exit 1
fi



IS_AUTO=$NO
IS_YESTOALL=$NO
IS_WIZARD=$NO
IS_DRY=$NO
IS_DEV=$NO

INSTALL_PANEL=$NO
INSTALL_CLERK=$NO
INSTALL_BACKUPS=$NO
INSTALL_FW=$NO
INSTALL_DNS=$NO
INSTALL_WEB=$NO
INSTALL_PHP=$NO
INSTALL_DB=$NO
INSTALL_MAIL=$NO
INSTALL_MC=$NO
INSTALL_GC=$NO
INSTALL_MQTT=$NO
INSTALL_SOFTREPOS=$NO
INSTALL_ZFS=$NO

VERBOSE=$NO
while [ $# -gt 0 ]; do
	case "$1" in
	-a|--auto)                               IS_AUTO=$YES     ;;
	-y|--yes|--assumeyes)                    IS_YESTOALL=$YES ;;
	-D|--dry)                                IS_DRY=$YES      ;;
	-T|--test|--testing|--dev|--development) IS_DEV=$YES      ;;
	-w|--wiz|--wizard|--ask)                 IS_WIZARD=$YES   ;;

	panel)                      INSTALL_PANEL=$YES     ;;
	clerk)                      INSTALL_CLERK=$YES     ;;
	backup|backups)             INSTALL_BACKUPS=$YES   ;;
	fw)                         INSTALL_FW=$YES        ;;
	dns)                        INSTALL_DNS=$YES       ;;
	web|nginx)                  INSTALL_WEB=$YES       ;;
	php)                        INSTALL_PHP=$YES       ;;
	db|data|database|databases) INSTALL_DB=$YES        ;;
	mail|email|e-mail)          INSTALL_MAIL=$YES      ;;
	mc)                         INSTALL_MC=$YES        ;;
	gc)                         INSTALL_GC=$YES        ;;
	mqtt)                       INSTALL_MQTT=$YES      ;;
	repo|repos)                 INSTALL_SOFTREPOS=$YES ;;
	zfs)                        INSTALL_ZFS=$YES       ;;

	-v|--verbose) VERBOSE=$YES ;;
	-V|--version) DisplayVersion ; exit 1 ;;
	-h|--help)    DisplayHelp    ; exit 1 ;;

	*)
		failure "Unknown argument: $1" ; failure
		DisplayHelp ; exit 1
	;;

	esac
	\shift
done



DisplayHeader



# run only as root
if [[ $EUID -ne 0 ]]; then
	failure "Please run this script as root"
	failure ; exit 1
fi



notice "Detected: $OS_TITLE"
if [[ $IS_DRY -eq $YES ]]; then
	notice "Dry-run"
fi
if [[ $IS_AUTO -eq $YES ]]; then
	notice "Auto"
fi
if [[ $IS_YESTOALL -eq $YES ]]; then
	notice "Yes-to-all"
fi
if [[ $IS_WIZARD -eq $YES ]]; then
	notice "Wizard"
fi
if [[ $IS_DEV -eq $YES ]]; then
	notice "Test/Dev Versions"
fi
echo
DID_SOMETHING=$NO



# detect already installed
[[ -e /etc/yum.repos.d/pxn-testing.repo                 ]] && IS_DEV=$YES
[[ -e /etc/configer/services/90-configer-panel-web.conf ]] && INSTALL_PANEL=$YES
[[ -e /etc/configer/services/90-clerk-web.conf          ]] && INSTALL_CLERK=$YES
[[ -e /etc/configer/services/95-xbackup.conf            ]] && INSTALL_BACKUPS=$YES
[[ -e /etc/configer/services/5-fw.conf                  ]] && INSTALL_FW=$YES
[[ -e /etc/configer/services/10-named.conf              ]] && INSTALL_DNS=$YES
[[ -e /etc/configer/services/70-web-setup.conf          ]] && INSTALL_WEB=$YES
[[ -e /etc/configer/services/80-php-fpm.conf            ]] && INSTALL_PHP=$YES
#TODO
#[[ -e /etc/configer/services/90-....conf                ]] && INSTALL_DB=$YES
[[ -e /etc/configer/services/11-postfix.conf            ]] && INSTALL_MAIL=$YES
[[ -e /etc/configer/services/50-mc.conf                 ]] && INSTALL_MC=$YES
[[ -e /etc/configer/services/80-gc.conf                 ]] && INSTALL_GC=$YES
[[ -e /etc/configer/services/70-mosquitto.conf          ]] && INSTALL_MQTT=$YES
[[ -e /etc/configer/services/80-repo-update.conf        ]] && INSTALL_SOFTREPOS=$YES
[[ -e /etc/configer/services/90-zfs.conf                ]] && INSTALL_ZFS=$YES



function doWizard() {
	while true; do
		\clear
		echo
		DisplayHeader
		if [[ $INSTALL_PANEL     -eq $YES ]]; then echo -n "  [X]" ; else echo -n "  [ ]" ; fi ; echo " p) Panel"
		if [[ $INSTALL_CLERK     -eq $YES ]]; then echo -n "  [X]" ; else echo -n "  [ ]" ; fi ; echo " k) Clerk"
		if [[ $INSTALL_BACKUPS   -eq $YES ]]; then echo -n "  [X]" ;                             echo " b) Backups"                ; fi
		if [[ $INSTALL_FW        -eq $YES ]]; then echo -n "  [X]" ;                             echo " f) Firewall (iptables)"    ; fi
		if [[ $INSTALL_DNS       -eq $YES ]]; then echo -n "  [X]" ; else echo -n "  [ ]" ; fi ; echo " d) DNS (bind/named)"
		if [[ $INSTALL_WEB       -eq $YES ]]; then echo -n "  [X]" ; else echo -n "  [ ]" ; fi ; echo " w) Web (nginx/haproxy)"
		if [[ $INSTALL_PHP       -eq $YES ]]; then echo -n "  [X]" ; else echo -n "  [ ]" ; fi ; echo " h) PHP"
		if [[ $INSTALL_DB        -eq $YES ]]; then echo -n "  [X]" ;                             echo " a) DB (sqlite/mysql)"      ; fi
		if [[ $INSTALL_MAIL      -eq $YES ]]; then echo -n "  [X]" ;                             echo " m) Mail (postfix/dovecot)" ; fi
		if [[ $INSTALL_MC        -eq $YES ]]; then echo -n "  [X]" ; else echo -n "  [ ]" ; fi ; echo " c) Minecraft"
		if [[ $INSTALL_GC        -eq $YES ]]; then echo -n "  [X]" ;                             echo " g) GrowControl"            ; fi
		if [[ $INSTALL_MQTT      -eq $YES ]]; then echo -n "  [X]" ; else echo -n "  [ ]" ; fi ; echo " q) MQTT"
		if [[ $INSTALL_SOFTREPOS -eq $YES ]]; then echo -n "  [X]" ;                             echo " c) Repo"                   ; fi
		if [[ $INSTALL_ZFS       -eq $YES ]]; then echo -n "  [X]" ;                             echo " z) ZFS"                    ; fi
		echo
		if [[ $IS_DEV      -eq $YES ]]; then echo -n "  [X]" ; else echo -n "  [ ]" ; fi ; echo " t) test/dev versions"
		if [[ $IS_YESTOALL -eq $YES ]]; then echo -n "  [X]" ; else echo -n "  [ ]" ; fi ; echo " y) yes to all (dnf -y)"
		echo "      i) continue install"
		echo "   quit) exit/cancel"
		echo
		echo "  (does not remove existing packages)"
		echo " Make a selection or press i to continue install"
		echo -n " > "
		read answer
		if [[ -z $answer ]]; then
			continue
		fi
		if [[ "$answer" == "i" ]] \
		|| [[ "$answer" == "install" ]]; then
			break
		fi
		case "$answer" in
		quit|exit|cancel) exit 2 ;;
		p|pan|panel)      if [[ $INSTALL_PANEL   -eq $YES ]]; then INSTALL_PANEL=$NO   ; else INSTALL_PANEL=$YES   ; fi ;;
		k|clerk)          if [[ $INSTALL_CLERK   -eq $YES ]]; then INSTALL_CLERK=$NO   ; else INSTALL_CLERK=$YES   ; fi ;;
		b|backup|backups) if [[ $INSTALL_BACKUPS -eq $YES ]]; then INSTALL_BACKUPS=$NO ; else INSTALL_BACKUPS=$YES ; fi ;;
		f|fw|firewall)    if [[ $INSTALL_FW      -eq $YES ]]; then INSTALL_FW=$NO      ; else INSTALL_FW=$YES      ; fi ;;
		d|dns|named)      if [[ $INSTALL_DNS     -eq $YES ]]; then INSTALL_DNS=$NO     ; else INSTALL_DNS=$YES     ; fi ;;
		w|web|nginx)      if [[ $INSTALL_WEB     -eq $YES ]]; then INSTALL_WEB=$NO     ; else INSTALL_WEB=$YES     ; fi ;;
		h|php)            if [[ $INSTALL_PHP     -eq $YES ]]; then INSTALL_PHP=$NO     ; else INSTALL_PHP=$YES     ; fi ;;
		a|db|data|database|databases)   if [[ $INSTALL_DB   -eq $YES ]]; then INSTALL_DB=$NO   ; else INSTALL_DB=$YES   ; fi ;;
		m|mail|email|e-mail)            if [[ $INSTALL_MAIL -eq $YES ]]; then INSTALL_MAIL=$NO ; else INSTALL_MAIL=$YES ; fi ;;
		c|mc|minecraft)                 if [[ $INSTALL_MC   -eq $YES ]]; then INSTALL_MC=$NO   ; else INSTALL_MC=$YES   ; fi ;;
		g|gc|growcontrol)               if [[ $INSTALL_GC   -eq $YES ]]; then INSTALL_GC=$NO   ; else INSTALL_GC=$YES   ; fi ;;
		q|mqtt|mosquitto)               if [[ $INSTALL_MQTT -eq $YES ]]; then INSTALL_MQTT=$NO ; else INSTALL_MQTT=$YES ; fi ;;
		r|repo|repos)    if [[ $INSTALL_SOFTREPOS -eq $YES ]]; then INSTALL_SOFTREPOS=$NO ; else INSTALL_SOFTREPOS=$YES ; fi ;;
		z|zfs)                          if [[ $INSTALL_ZFS  -eq $YES ]]; then INSTALL_ZFS=$NO  ; else INSTALL_ZFS=$YES  ; fi ;;
		t|test|testing|dev|development) if [[ $IS_DEV       -eq $YES ]]; then IS_DEV=$NO       ; else IS_DEV=$YES       ; fi ;;
		y|yes)                          if [[ $IS_YESTOALL  -eq $YES ]]; then IS_YESTOALL=$NO  ; else IS_YESTOALL=$YES  ; fi ;;
		*) failure "Unknown selection: $answer" ; sleep 2 ;;
		esac
	done
	echo ; echo
}
if [[ $IS_WIZARD -eq $YES ]]; then
	doWizard
fi



function doInstall() {
	if [[ -z $1 ]]; then
		failure "No package argument provided to doInstall()"
		failure ; exit 1
	fi
	if [[ -z $2 ]]; then
		local TITLE="${1/ /, }"
	else
		local TITLE="$2"
	fi
	title "Installing $TITLE.."
	local Y_FLAG=""
	if [[ $IS_YESTOALL -eq $YES ]]; then
		local Y_FLAG="-y"
	fi
	if [[ $IS_DRY -eq $YES ]]; then
		echo "Skipping.."
	fi
	echo " > dnf install $1"
	if [[ $IS_DRY -ne $YES ]]; then
		\dnf install $Y_FLAG  $1  || exit 1
	fi
	echo
}

function doUpdate() {
	title "Updating.."
	local Y_FLAG=""
	if [[ $IS_YESTOALL -eq $YES ]]; then
		local Y_FLAG="-y"
	fi
	if [[ $IS_DRY -eq $YES ]]; then
		echo "Skipping.."
	fi
	echo " > dnf update"
	if [[ $IS_DRY -ne $YES ]]; then
		\dnf update $Y_FLAG  || exit 1
	fi
	echo
}



# pxn.repo
if [[ ! -f /etc/yum.repos.d/pxn.repo ]]; then
	doInstall  "https://yum.poixson.com/latest.rpm"  "pxn repo"
fi
if [[ ! -f /etc/yum.repos.d/pxn-testing.repo ]]; then
	if [[ $IS_DEV -eq $YES ]]; then
		doInstall  "pxn-testing-release"  "pxn testing repo"
	fi
fi

# epel repo
if [[ "$OS_NAME" == "centos" ]] || [[ "$OS_NAME" == "rocky" ]]; then
	if [[ ! -f /etc/yum.repos.d/epel.repo ]]; then
		doInstall  epel-release  "epel repo"
	fi
fi

# nginx repo
if [[ $INSTALL_NGINX -eq $YES ]] \
&& [[ ! -f /etc/yum.repos.d/nginx.repo ]]; then
	if [[ "$OS_NAME" == "centos" ]] || [[ "$OS_NAME" == "rocky" ]]; then
		doInstall  nginx-release  "nginx repo"
	fi
fi



# php
if [[ $INSTALL_PHP   -eq $YES ]] \
|| [[ $INSTALL_PANEL -eq $YES ]] \
|| [[ $INSTALL_CLERK -eq $YES ]]; then
	title "PHP Module.."
	# remi repo
	if [[ -z $REMI_RELEASE_URL ]]; then
		failure "Remi repo not set for this OS."
		failure ; exit 1
	fi
	if [[ ! -f /etc/yum.repos.d/remi.repo ]]; then
		doInstall  "$REMI_RELEASE_URL"  "remi repo"
	fi
	Y_FLAG=""
	if [[ $IS_YESTOALL -eq $YES ]]; then
		Y_FLAG="-y"
	fi
	if [[ $IS_DRY -eq $YES ]]; then
		echo "Skipping.."
	fi
	echo " > dnf module reset  php"
	if [[ $IS_DRY -ne $YES ]]; then
		\dnf module reset $Y_FLAG php  || exit 1
	fi
	echo
	echo " > dnf module install  php:remi-8.2"
	if [[ $IS_DRY -ne $YES ]]; then
		\dnf module install $Y_FLAG php:remi-8.2  || exit 1
	fi
fi



doUpdate
[[ ! -e /usr/bin/pxn/scripts/common.sh ]] && \
	doInstall  pxn-scripts  "pxnScripts"
doInstall  configer  "Configer"

INSTALL_PACKAGES=""
[[ $INSTALL_PANEL     -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-panel"
[[ $INSTALL_CLERK     -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-clerk"
[[ $INSTALL_BACKUPS   -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-backups"
[[ $INSTALL_FW        -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-fw"
[[ $INSTALL_DNS       -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-dns"
[[ $INSTALL_WEB       -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-web"
[[ $INSTALL_PHP       -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-php"
[[ $INSTALL_DB        -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-db"
[[ $INSTALL_MAIL      -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-mail"
[[ $INSTALL_MC        -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-mc"
[[ $INSTALL_GC        -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-gc"
[[ $INSTALL_MQTT      -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-mqtt"
[[ $INSTALL_SOFTREPOS -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-softrepos"
[[ $INSTALL_ZFS       -eq $YES ]] && INSTALL_PACKAGES="$INSTALL_PACKAGES configer-zfs"

if [[ ! -z $INSTALL_PACKAGES ]]; then
	doInstall "$INSTALL_PACKAGES" "Configer packages"
	DID_SOMETHING=$YES
fi

# update system
doUpdate



if [[ $DID_SOMETHING -ne $YES ]]; then
	warning "Didn't install any Configer service packages"
	echo "for more info:"
	echo "  $0 --help"
	echo
	exit 1
fi

if [[ $IS_AUTO -eq $YES ]]; then
	echo "script-auto" > /etc/configer/origin.conf
elif [[ $IS_WIZARD -eq $YES ]]; then
	echo "script-wizard" > /etc/configer/origin.conf
else
	echo "script" > /etc/configer/origin.conf
fi
echo " Finished installing Configer"
echo
exit 0
