#!/bin/bash
# Copyright (c) 2000-2017 Synology Inc. All rights reserved.

PKG_NAME="DokuWiki"
PKG_DIR="dokuwiki"
WEBSITE_ROOT="/var/services/web/$PKG_DIR"
INFO_FILE="/usr/syno/etc/packages/$PKG_NAME/$PKG_DIR.conf"
PAGE_INST="$PAGE_RESTORE $MAIN_INSTALL"
PAGE_UPGRADE="$MAIN_UPGRADE"
CONF_FILE="conf/local.php"

CustomSetPages()
{
	NEW_INSTALL_PAGES=""
	RESTORE_PAGES="$(PageRestore)"
}

CustomHasRunWebsiteSetup()
{
	# initial setup for Dokuwiki is optional, it does not indicate the need for upgrade migration
	# there is no difference between setup-done and setup-required
	true
}

# workaround for not creating wizard
MainCreate()
{
	local output="$1"
	local pages="$2"
	local main_function="$3"
	local lan
	
	# skip uninstall wizard
	if [ "$main_function" == "main_uninst" ]; then
		return
	fi
	for dir in lang/*; do
		lan=$(basename "$dir")
		cat "wizard_common" > "${output}_${lan}.sh"
		cat "lang/$lan" "wizard_customized" $pages "$main_function" >> "${output}_${lan}.sh"
		CustomWizCreate "${output}_${lan}.sh"
	done
	chmod +x "${output}"*.sh
	cp -a "${output}_${DEFAULT}.sh" "${output}.sh"
}

