xref: /illumos-gate/usr/src/test/os-tests/tests/idmap/idmap_init.ksh (revision 7f3d7c9289dee6488b3cd2848a68c0b8580d750c)
1#!/bin/ksh
2
3#
4# This file and its contents are supplied under the terms of the
5# Common Development and Distribution License ("CDDL"), version 1.0.
6# You may only use this file in accordance with the terms of version
7# 1.0 of the CDDL.
8#
9# A full copy of the text of the CDDL should have accompanied this
10# source.  A copy of the CDDL is also available via the Internet at
11# http://www.illumos.org/license/CDDL.
12#
13
14#
15# Copyright 2025 MNX Cloud, Inc.
16#
17
18# Enable idmap temporarily for this test if it's not already enabled.
19# Skip test if it can't be enabled.
20
21SVC=svc:/system/idmap
22
23if svcs -H -o state $SVC >/dev/null 2>&1; then
24	pretest_idmap_state=$(svcs -H -o state $SVC)
25else
26	echo "Unknown service $SVC - skipping idmap tests" | tee /dev/stderr
27	exit 4
28fi
29
30echo $pretest_idmap_state > /var/run/idmap-test-smf
31if [ "$pretest_idmap_state" == "disabled" ]; then
32	svcadm enable -st $SVC
33	if [ $? != 0 ]; then
34		echo "Failed to enable $SVC - skipping idmap tests" | tee /dev/stderr
35		exit 4
36	fi
37	echo "Service $SVC temporarily enabled for idmap tests"
38fi
39exit 0
40