2001-11-19 17:18:44 +01:00
|
|
|
# start of install
|
|
|
|
#
|
2002-06-27 22:46:31 +02:00
|
|
|
# $NetBSD: install,v 1.10 2002/06/27 20:46:31 jlam Exp $
|
2001-11-19 17:18:44 +01:00
|
|
|
|
|
|
|
case ${STAGE} in
|
|
|
|
PRE-INSTALL)
|
2002-06-20 22:15:46 +02:00
|
|
|
_pkg_exit=0
|
|
|
|
_print_line=1
|
|
|
|
_print_group=1
|
|
|
|
if [ -n "${PKG_GROUPS}" ]; then
|
2001-11-26 21:37:38 +01:00
|
|
|
eval set -- ${PKG_GROUPS}
|
2002-06-20 22:15:46 +02:00
|
|
|
for groupset; do
|
|
|
|
save_IFS="${IFS}"; IFS=":"
|
|
|
|
set -- ${groupset}
|
|
|
|
group="$1"; groupid="$2"
|
|
|
|
IFS="${save_IFS}"
|
|
|
|
|
|
|
|
# We need to check that ${PKG_GROUP} exists before
|
|
|
|
# adding the user. Do it with chgrp to be able to
|
|
|
|
# use NIS.
|
|
|
|
#
|
|
|
|
${TOUCH} /tmp/grouptest.$$
|
|
|
|
if ${CHGRP} ${group} /tmp/grouptest.$$ >/dev/null 2>&1; then
|
2001-11-26 21:37:38 +01:00
|
|
|
${ECHO} "Group '${group}' already exists."
|
2002-06-20 22:15:46 +02:00
|
|
|
elif [ "${_PKG_CREATE_USERGROUP}" = "NO" ]; then
|
|
|
|
if [ ${_print_line} -gt 0 ]; then
|
|
|
|
_print_line=0
|
|
|
|
${CAT} << EOF
|
|
|
|
===========================================================================
|
|
|
|
EOF
|
|
|
|
if [ ${_print_group} -gt 0 ]; then
|
|
|
|
_print_group=0
|
|
|
|
${CAT} << EOF
|
|
|
|
The following groups need to be created for ${PKGNAME}:
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -z "${groupid}" ]; then
|
|
|
|
groupid_str=
|
|
|
|
else
|
|
|
|
groupid_str=" (${groupid})"
|
|
|
|
fi
|
|
|
|
${ECHO} " ${group}${groupid_str}"
|
|
|
|
_pkg_exit=1
|
|
|
|
else
|
2001-11-26 21:37:38 +01:00
|
|
|
groupid_option=
|
2002-06-20 22:15:46 +02:00
|
|
|
if [ -n "${groupid}" ]; then
|
2001-12-04 22:05:06 +01:00
|
|
|
groupid_option="-g"
|
2001-11-26 21:37:38 +01:00
|
|
|
fi
|
|
|
|
${ECHO} "Creating group: ${group}"
|
2001-12-04 22:05:06 +01:00
|
|
|
${GROUPADD} ${groupid_option} ${groupid} "${group}"
|
2002-06-20 22:15:46 +02:00
|
|
|
fi
|
|
|
|
${RM} -f /tmp/grouptest.$$
|
2001-11-26 21:37:38 +01:00
|
|
|
done
|
2001-11-19 17:18:44 +01:00
|
|
|
fi
|
2002-06-20 22:15:46 +02:00
|
|
|
_print_user=1
|
|
|
|
if [ -n "${PKG_USERS}" ]; then
|
2001-11-26 21:37:38 +01:00
|
|
|
eval set -- ${PKG_USERS}
|
2002-06-20 22:15:46 +02:00
|
|
|
for userset; do
|
|
|
|
save_IFS="${IFS}"; IFS=":"
|
|
|
|
set -- ${userset}
|
|
|
|
user="$1"; group="$2"; userid="$3"
|
|
|
|
descr="${4:-${PKGBASE} ${user} user}"
|
|
|
|
home="${5:-@PKG_USER_HOME@}"
|
|
|
|
shell="${6:-@PKG_USER_SHELL@}"
|
|
|
|
IFS="${save_IFS}"
|
|
|
|
|
|
|
|
# Use `id' to be able to use NIS.
|
|
|
|
if ${ID} "${user}" >/dev/null 2>&1; then
|
2001-11-26 21:37:38 +01:00
|
|
|
${ECHO} "User '${user}' already exists."
|
2002-06-20 22:15:46 +02:00
|
|
|
elif [ "${_PKG_CREATE_USERGROUP}" = "NO" ]; then
|
|
|
|
if [ ${_print_line} -gt 0 ]; then
|
|
|
|
_print_line=0
|
|
|
|
${CAT} << EOF
|
|
|
|
===========================================================================
|
|
|
|
EOF
|
|
|
|
elif [ ${_print_group} -eq 0 ]; then
|
|
|
|
_print_group=1
|
|
|
|
${ECHO} "";
|
|
|
|
fi
|
|
|
|
if [ ${_print_user} -gt 0 ]; then
|
|
|
|
_print_user=0
|
|
|
|
${CAT} << EOF
|
|
|
|
The following users need to be created for ${PKGNAME}:
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
if [ -z "${userid}" ]; then
|
|
|
|
userid_str=
|
|
|
|
else
|
|
|
|
userid_str=" (${userid})"
|
|
|
|
fi
|
|
|
|
${ECHO} " ${user}${userid_str}: ${group}, ${home}, ${shell}"
|
|
|
|
_pkg_exit=1
|
|
|
|
else
|
2001-11-26 21:37:38 +01:00
|
|
|
userid_option=
|
2002-06-20 22:15:46 +02:00
|
|
|
if [ -n "${userid}" ]; then
|
2001-12-04 22:05:06 +01:00
|
|
|
userid_option="-u"
|
2001-11-26 21:37:38 +01:00
|
|
|
fi
|
|
|
|
${ECHO} "Creating user: ${user}"
|
|
|
|
${USERADD} -c "${descr}" \
|
2001-12-04 22:05:06 +01:00
|
|
|
${userid_option} ${userid} \
|
2001-11-26 21:37:38 +01:00
|
|
|
-g "${group}" \
|
|
|
|
-d "${home}" \
|
|
|
|
-s "${shell}" \
|
|
|
|
"${user}"
|
2002-06-20 22:15:46 +02:00
|
|
|
fi
|
2001-11-26 21:37:38 +01:00
|
|
|
done
|
2001-11-19 17:18:44 +01:00
|
|
|
fi
|
2002-06-20 22:15:46 +02:00
|
|
|
if [ ${_print_line} -eq 0 ]; then
|
|
|
|
${CAT} << EOF
|
|
|
|
===========================================================================
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
if [ ${_pkg_exit} -gt 0 ]; then
|
|
|
|
exit ${_pkg_exit}
|
|
|
|
fi
|
2001-11-19 17:18:44 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
POST-INSTALL)
|
|
|
|
# Create package directories.
|
2002-06-20 22:15:46 +02:00
|
|
|
_print_line=1
|
|
|
|
_print_dirs=1
|
|
|
|
if [ -n "${MAKE_DIRS}" -o -n "${OWN_DIRS}" -o \
|
|
|
|
-n "${MAKE_DIRS_PERMS}" -o -n "${OWN_DIRS_PERMS}" ]; then
|
|
|
|
eval set -- ${MAKE_DIRS} ${OWN_DIRS}
|
|
|
|
for dir; do
|
2002-06-27 22:46:31 +02:00
|
|
|
if [ -d "${dir}" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2002-06-20 22:15:46 +02:00
|
|
|
if [ "${_PKG_CONFIG}" = "NO" ]; then
|
|
|
|
if [ ${_print_line} -gt 0 ]; then
|
|
|
|
_print_line=0
|
|
|
|
${CAT} << EOF
|
|
|
|
===========================================================================
|
|
|
|
EOF
|
|
|
|
if [ ${_print_dirs} -gt 0 ]; then
|
|
|
|
_print_dirs=0
|
|
|
|
${CAT} << EOF
|
|
|
|
The following directories should be created for ${PKGNAME}:
|
2001-11-19 17:18:44 +01:00
|
|
|
|
2002-06-20 22:15:46 +02:00
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
${ECHO} " ${dir}"
|
|
|
|
else
|
|
|
|
${MKDIR} "${dir}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
eval set -- ${MAKE_DIRS_PERMS} ${OWN_DIRS_PERMS}
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
dir="$1"; owner="$2"; group="$3"; mode="$4"
|
|
|
|
shift; shift; shift; shift
|
|
|
|
if [ "${_PKG_CONFIG}" = "NO" ]; then
|
|
|
|
if [ ${_print_line} -gt 0 ]; then
|
|
|
|
_print_line=0
|
|
|
|
${CAT} << EOF
|
|
|
|
===========================================================================
|
|
|
|
EOF
|
|
|
|
if [ ${_print_dirs} -gt 0 ]; then
|
|
|
|
_print_dirs=0
|
|
|
|
${CAT} << EOF
|
|
|
|
The following directories should be created for ${PKGNAME}:
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
${ECHO} " ${dir} (o=${owner}, g=${group}, m=${mode})"
|
|
|
|
else
|
|
|
|
${MKDIR} "${dir}"
|
|
|
|
${CHOWN} "${owner}" "${dir}"
|
|
|
|
${CHGRP} "${group}" "${dir}"
|
|
|
|
${CHMOD} "${mode}" "${dir}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
_print_files=1
|
|
|
|
if [ "${_PKG_CONFIG}" = "YES" ]; then
|
|
|
|
if [ -n "${CONF_FILES}" -o \
|
|
|
|
-n "${CONF_FILES_PERMS}" -o \
|
|
|
|
-n "${SUPPORT_FILES}" -o \
|
|
|
|
-n "${SUPPORT_FILES_PERMS}" -o \
|
|
|
|
-n "${RCD_SCRIPTS}" ]; then
|
|
|
|
${CAT} << EOF
|
|
|
|
Installing configuration files for ${PKGNAME}:
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
2001-11-19 17:18:44 +01:00
|
|
|
fi
|
2001-11-26 15:48:53 +01:00
|
|
|
eval set -- ${CONF_FILES}
|
2002-06-20 22:15:46 +02:00
|
|
|
while [ $# -gt 0 ]; do
|
2001-11-19 17:18:44 +01:00
|
|
|
samplefile="$1"; file="$2"
|
|
|
|
shift; shift
|
|
|
|
|
2002-06-20 22:15:46 +02:00
|
|
|
if [ "${_PKG_CONFIG}" = "NO" ]; then
|
|
|
|
if [ ${_print_line} -gt 0 ]; then
|
|
|
|
_print_line=0
|
|
|
|
${CAT} << EOF
|
|
|
|
===========================================================================
|
|
|
|
EOF
|
|
|
|
elif [ ${_print_dirs} -eq 0 ]; then
|
|
|
|
_print_dirs=1
|
|
|
|
${ECHO} "";
|
|
|
|
fi
|
|
|
|
if [ ${_print_files} -gt 0 ]; then
|
|
|
|
_print_files=0
|
|
|
|
${CAT} << EOF
|
|
|
|
The following files should be created for ${PKGNAME}:
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
${ECHO} " ${file} (m=@CONF_FILES_MODE@)"
|
|
|
|
elif [ -e "${file}" ]; then
|
2002-01-23 16:02:27 +01:00
|
|
|
${ECHO} " ${file} already exists, example file is"
|
|
|
|
${ECHO} " ${samplefile}"
|
2001-11-19 17:18:44 +01:00
|
|
|
else
|
2002-06-20 22:15:46 +02:00
|
|
|
if [ -e "${samplefile}" ]; then
|
2001-11-26 21:37:38 +01:00
|
|
|
${ECHO} " ${file}"
|
|
|
|
${CP} "${samplefile}" "${file}"
|
|
|
|
${CHMOD} @CONF_FILES_MODE@ "${file}"
|
|
|
|
fi
|
2001-11-19 17:18:44 +01:00
|
|
|
fi
|
|
|
|
done
|
2001-11-26 15:48:53 +01:00
|
|
|
eval set -- ${SUPPORT_FILES}
|
2002-06-20 22:15:46 +02:00
|
|
|
while [ $# -gt 0 ]; do
|
2001-11-20 00:33:52 +01:00
|
|
|
samplefile="$1"; file="$2"
|
|
|
|
shift; shift
|
2001-11-19 17:18:44 +01:00
|
|
|
|
2002-06-20 22:15:46 +02:00
|
|
|
if [ "${_PKG_CONFIG}" = "NO" ]; then
|
|
|
|
if [ ${_print_line} -gt 0 ]; then
|
|
|
|
_print_line=0
|
|
|
|
${CAT} << EOF
|
|
|
|
===========================================================================
|
|
|
|
EOF
|
|
|
|
elif [ ${_print_dirs} -eq 0 ]; then
|
|
|
|
_print_dirs=1
|
|
|
|
${ECHO} "";
|
|
|
|
fi
|
|
|
|
if [ ${_print_files} -gt 0 ]; then
|
|
|
|
_print_files=0
|
|
|
|
${CAT} << EOF
|
|
|
|
The following files should be created for ${PKGNAME}:
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
${ECHO} " ${file} (m=@SUPPORT_FILES_MODE@)"
|
|
|
|
elif [ -e "${file}" ]; then
|
2002-01-23 16:01:08 +01:00
|
|
|
${ECHO} " ${file} already exists, example file is"
|
|
|
|
${ECHO} " ${samplefile}"
|
2001-11-19 17:18:44 +01:00
|
|
|
else
|
2002-06-20 22:15:46 +02:00
|
|
|
if [ -e "${samplefile}" ]; then
|
2001-11-26 21:37:38 +01:00
|
|
|
${ECHO} " ${file}"
|
|
|
|
${CP} "${samplefile}" "${file}"
|
|
|
|
${CHMOD} @SUPPORT_FILES_MODE@ "${file}"
|
|
|
|
fi
|
2001-11-19 17:18:44 +01:00
|
|
|
fi
|
|
|
|
done
|
2001-11-26 15:48:53 +01:00
|
|
|
eval set -- ${CONF_FILES_PERMS} ${SUPPORT_FILES_PERMS}
|
2002-06-20 22:15:46 +02:00
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
samplefile="$1"; file="$2"
|
|
|
|
owner="$3"; group="$4"; mode="$5"
|
2001-11-20 00:33:52 +01:00
|
|
|
shift; shift; shift; shift; shift
|
2001-11-19 17:18:44 +01:00
|
|
|
|
2002-06-20 22:15:46 +02:00
|
|
|
if [ "${_PKG_CONFIG}" = "NO" ]; then
|
|
|
|
if [ ${_print_line} -gt 0 ]; then
|
|
|
|
_print_line=0
|
|
|
|
${CAT} << EOF
|
|
|
|
===========================================================================
|
|
|
|
EOF
|
|
|
|
elif [ ${_print_dirs} -eq 0 ]; then
|
|
|
|
_print_dirs=1
|
|
|
|
${ECHO} "";
|
|
|
|
fi
|
|
|
|
if [ ${_print_files} -gt 0 ]; then
|
|
|
|
_print_files=0
|
|
|
|
${CAT} << EOF
|
|
|
|
The following files should be created for ${PKGNAME}:
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
${ECHO} " ${file} (o=${owner}, g=${group}, m=${mode})"
|
|
|
|
elif [ -e ${file} ]; then
|
2002-01-23 16:02:27 +01:00
|
|
|
${ECHO} " ${file} already exists, example file is"
|
|
|
|
${ECHO} " ${samplefile}"
|
2001-11-19 17:18:44 +01:00
|
|
|
else
|
2002-06-20 22:15:46 +02:00
|
|
|
if [ -e "${samplefile}" ]; then
|
2001-11-26 21:37:38 +01:00
|
|
|
${ECHO} " ${file}"
|
|
|
|
${CP} "${samplefile}" "${file}"
|
|
|
|
${CHOWN} "${owner}" "${file}"
|
|
|
|
${CHGRP} "${group}" "${file}"
|
|
|
|
${CHMOD} ${mode} "${file}"
|
|
|
|
fi
|
2001-11-19 17:18:44 +01:00
|
|
|
fi
|
|
|
|
done
|
2001-11-26 15:48:53 +01:00
|
|
|
eval set -- ${RCD_SCRIPTS}
|
2002-06-20 22:15:46 +02:00
|
|
|
for script; do
|
2001-11-26 15:48:53 +01:00
|
|
|
samplefile="${PKG_PREFIX}/etc/rc.d/${script}"
|
|
|
|
file="${RCD_SCRIPTS_DIR}/${script}"
|
2001-11-19 17:18:44 +01:00
|
|
|
|
2002-06-20 22:15:46 +02:00
|
|
|
if [ "${_PKG_CONFIG}" = "NO" ]; then
|
|
|
|
if [ ${_print_line} -gt 0 ]; then
|
|
|
|
_print_line=0
|
|
|
|
${CAT} << EOF
|
|
|
|
===========================================================================
|
|
|
|
EOF
|
|
|
|
elif [ ${_print_dirs} -eq 0 ]; then
|
|
|
|
_print_dirs=1
|
|
|
|
${ECHO} "";
|
|
|
|
fi
|
|
|
|
if [ ${_print_files} -gt 0 ]; then
|
|
|
|
_print_files=0
|
|
|
|
${CAT} << EOF
|
|
|
|
The following files should be created for ${PKGNAME}:
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
${ECHO} " ${file} (m=@RCD_SCRIPTS_MODE@)"
|
|
|
|
elif [ -e "${file}" ]; then
|
2002-01-23 16:02:27 +01:00
|
|
|
${ECHO} " ${file} already exists, example file is"
|
|
|
|
${ECHO} " ${samplefile}"
|
2001-11-19 17:18:44 +01:00
|
|
|
else
|
2002-06-20 22:15:46 +02:00
|
|
|
if [ -e "${samplefile}" ]; then
|
2001-11-26 21:37:38 +01:00
|
|
|
${ECHO} " ${file}"
|
|
|
|
${CP} "${samplefile}" "${file}"
|
|
|
|
${CHMOD} @RCD_SCRIPTS_MODE@ "${file}"
|
|
|
|
fi
|
2001-11-19 17:18:44 +01:00
|
|
|
fi
|
|
|
|
done
|
2002-06-20 22:15:46 +02:00
|
|
|
if [ ${_print_line} -eq 0 ]; then
|
2001-11-19 17:18:44 +01:00
|
|
|
${CAT} << EOF
|
2002-06-20 22:15:46 +02:00
|
|
|
===========================================================================
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
if [ "${_PKG_CONFIG}" = "YES" ]; then
|
|
|
|
if [ -n "${CONF_FILES}" -o -n "${CONF_FILES_PERMS}" ]; then
|
|
|
|
${CAT} << EOF
|
2001-11-19 17:18:44 +01:00
|
|
|
|
|
|
|
===========================================================================
|
2002-06-20 22:15:46 +02:00
|
|
|
You may wish to customize the following files for ${PKGNAME}:
|
2001-11-19 17:18:44 +01:00
|
|
|
|
|
|
|
EOF
|
2002-06-20 22:15:46 +02:00
|
|
|
eval set -- ${CONF_FILES}
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
samplefile="$1"; file="$2"
|
|
|
|
shift; shift
|
2001-11-19 17:18:44 +01:00
|
|
|
|
2002-06-20 22:15:46 +02:00
|
|
|
${ECHO} " ${file}"
|
|
|
|
done
|
|
|
|
eval set -- ${CONF_FILES_PERMS}
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
samplefile="$1"; file="$2"
|
|
|
|
owner="$3"; group="$4"; mode="$5"
|
|
|
|
shift; shift; shift; shift; shift
|
2001-11-19 17:18:44 +01:00
|
|
|
|
2002-06-20 22:15:46 +02:00
|
|
|
${ECHO} " ${file}"
|
|
|
|
done
|
|
|
|
${CAT} << EOF
|
2001-11-19 17:18:44 +01:00
|
|
|
===========================================================================
|
|
|
|
EOF
|
2002-06-20 22:15:46 +02:00
|
|
|
fi
|
2001-11-19 17:18:44 +01:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
${ECHO} "Unexpected argument: ${STAGE}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# end of install
|