fq_hostname()
{
	case `hostname` in
	*.*)	hostname;;
	*)	nslookup "`hostname`" 2>/dev/null | awk '/^Name:/ {print $2}';;
	esac
}

# NOTE: need to set $FQ_HOSTNAME before invoking dns_domainname
dns_domainname()
{
	[ X"$FQ_HOSTNAME" = X ] && ABORT '$FQ_HOSTNAME is not set'
	echo "$FQ_HOSTNAME" | sed 's/^[^.]*\.//'
}

memory_size()
{
	# XXX assume 64MB
	echo 64

	# XXX
	# lsattr -El sys0 -a realmem
}

number_of_cpus()
{
	lsdev -C | grep Process | wc -l
}

sysdep_defaults()
{
	# XXX not really confirmed
	: ${RC_DIR:="$CONFIG_PREFIX/sbin/init.d"}
	: ${RC_BASE_DIR:="/sbin"}
}

config_sysdep()
{
	# no conversion
	cat ${1+"$@"}
}

mkcnf_gfmd_sysdep()
{
	: # do nothing
}

mkcnf_gfsd_sysdep()
{
	: # do nothing
}

service_reg()
{
	: # do nothing
}

service_add()
{
	# local service levels start kill level d

	service=$1

	if [ -w / -a X"$CONFIG_PREFIX" = X ]; then
		levels=`awk '/^# +chkconfig: +/{print $3}' $RC_DIR/$service |
			sed 's/./& /g'`
		start=`awk '/^# +chkconfig: +/{print $4}' $RC_DIR/$service`
		kill=`awk '/^# +chkconfig: +/{print $5}' $RC_DIR/$service`
		for level in $levels; do
			d="$RC_BASE_DIR/rc$level.d"
			[ -d $d ] || continue
			rm -f "$d/S${start}$service" "$d/K${kill}$service"
			ln -s "$RC_DIR/$service" "$d/S${start}$service" &&
			ln -s "$RC_DIR/$service" "$d/K${kill}$service" ||
			ABORT "cannot add $service to $d"
		done
		echo added "$service" service
	else
		echo add "$service" service: skipped
	fi
}

service_remove()
{
	:
}

service_ctl()
{
	# local service ctl

	run_or_echo=
	if [ X"$1" = X-n ]; then
		run_or_echo=echo
		shift
	fi

	service=$1
	ctl=$2

	$run_or_echo "$RC_DIR/$service" $ctl || ABORT "cannot $ctl $service"
}

create_run_script()
{
	mkcnf ${1+"$@"}
	chmod +x "$1" || ABORT "cannot chmod +x $1"
}
