/usr/lib/oar/setup/common.sh is in oar-common 2.5.7-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | #! /bin/sh
set -e
#
# Variables defined during the oar installation process
#
PREFIX="/usr"
BINDIR="/usr/bin"
CGIDIR="/usr/lib/cgi-bin"
DOCDIR="/usr/share/doc/oar-common"
EXAMPLEDIR="/usr/share/doc/oar-common/examples"
ETCDIR="/etc"
OARCONFDIR="/etc/oar"
OARDIR="/usr/lib/oar"
SHAREDIR="/usr/share/oar/oar-common"
PERLLIBDIR="/usr/share/perl5"
RUNDIR="/var/run"
LOGDIR="/var/log"
MANDIR="/usr/share/man"
SBINDIR="/usr/sbin"
VARLIBDIR="/var/lib"
OARHOMEDIR="/var/lib/oar"
ROOTUSER="root"
ROOTGROUP="root"
OARDO_DEFAULTUSER="root"
OARDO_DEFAULTGROUP="oar"
OARUSER="oar"
OAROWNER="oar"
OAROWNERGROUP="oar"
WWWUSER="www-data"
APACHECONFDIR="/etc/apache2"
WWWROOTDIR="/var/www"
WWWDIR="/usr/share/oar-web-status"
XAUTHCMDPATH="/usr/bin/xauth"
OARSHCMD="oarsh_oardo"
INITDIR="/etc/init.d"
DEFAULTDIR="/etc/default"
SETUP_TYPE="deb"
TARGET_DIST="debian"
OARDOPATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/lib/oar/oardodo"
#
# shared functions for oar setup files.
#
install_conffile() {
case "${SETUP_TYPE}" in
"deb")
install_deb_conffile $*
;;
"rpm")
install_rpm_conffile $*
;;
"tgz"|*)
install_if_not_exist $*
;;
esac
}
install_deb_conffile() {
local src dst rights owner tmpfile package
src=$1
dst=$2
rights=$3
owner=$4
# PACKAGE need to be defined in the postinst before calling *-setup.
package=$PACKAGE
ucf --debconf-ok --three-way $src $dst
ucfr $package $dst
if [ -n "$rights" ]; then
chmod $rights $dst
fi
if [ -n "$owner" ]; then
chown $owner $dst
fi
if [ -f "$tmpfile" ]; then
rm -f "$tmpfile"
fi
}
install_rpm_conffile() {
# I've not found ucf or equivalent to install config file during postinst
# in the rpm world. So the config file are nstalled manually in the spec
# file.
local src dst rights owner tmpfile
src=$1
dst=$2
rights=$3
owner=$4
if [ -n "$rights" ]; then
chmod $rights $dst
fi
if [ -n "$owner" ]; then
chown $owner $dst
fi
}
install_if_not_exist() {
local src dst rights owner
src=$1
dst=$2
rights=$3
owner=$4
# Decompress the file, if compressed
tmpfile=
if [ ! -f "$src" ] && [ -f "${src}.gz" ]; then
tmpfile=$(tempfile)
zcat ${src}.gz > $tmpfile
src=$tmpfile
fi
if [ -f "$dst" ]; then
:
else
install $src $dst
if [ -n "$rights" ]; then
chmod $rights $dst
fi
if [ -n "$owner" ]; then
chown $owner $dst
fi
fi
if [ -f "$tmpfile" ]; then
rm -f "$tmpfile"
fi
}
set_rights() {
file=$1
perms=$2
owner=$3
group=$4
[ -n "$owner" ] && chown $owner $file
[ -n "$group" ] && chgrp $group $file
[ -n "$perms" ] && chmod $perms $file
}
create_oar_group() {
if ! getent group | grep -q "^${OAROWNERGROUP}:"; then
echo -n "Adding group ${OAROWNERGROUP}.."
case "$TARGET_DIST" in
"debian")
addgroup --quiet --system ${OAROWNERGROUP} 2>/dev/null || true
;;
*)
groupadd --system ${OAROWNERGROUP} 2>/dev/null >/dev/null || true
;;
esac
echo "..done"
fi
}
create_oar_home() {
test -d "${OARHOMEDIR}" || mkdir -p ${OARHOMEDIR}
}
create_oar_user() {
# Create oar user
if ! getent passwd | grep -q "^${OAROWNER}:"; then
echo -n "Adding system user ${OAROWNER}.."
case "$TARGET_DIST" in
"debian")
adduser --quiet \
--system \
--ingroup ${OAROWNERGROUP} \
--shell /bin/bash \
--no-create-home \
--disabled-password \
${OAROWNER} 2>/dev/null || true
;;
*)
useradd --system \
--gid ${OAROWNERGROUP} \
--shell /bin/bash \
--password "*" \
${OAROWNER} >/dev/null 2>&1
passwd -u ${OAROWNER} >/dev/null 2>&1 ||true
;;
esac
echo "..done"
fi
# Adjust the password entry
usermod -d ${OARHOMEDIR} \
-g ${OAROWNERGROUP} \
${OAROWNER}
# Adjust the file and directory permissions
case "$SETUP_TYPE" in
"deb")
if ! dpkg-statoverride --list ${OARHOMEDIR} >/dev/null; then
chown $OAROWNER:$OAROWNERGROUP $OARHOMEDIR
chmod u=rwx,g=rxs,o= $OARHOMEDIR
fi
;;
*)
chown $OAROWNER:$OAROWNERGROUP $OARHOMEDIR
chmod u=rwx,g=rxs,o= $OARHOMEDIR
;;
esac
# set OAR shell
if [ "`getent passwd ${OAROWNER} |cut -f7 -d:`" != "${OARDIR}/oarsh_shell" ]; then
chsh -s ${OARDIR}/oarsh_shell ${OAROWNER}
fi
# Fix the bash profile
cat > ${OARHOMEDIR}/.bash_oar <<EOF
#
# OAR bash environnement file for the oar user
#
# /!\ This file is automatically created at update installation/upgrade.
# Do not modify this file.
#
bash_oar() {
# Prevent to be executed twice or more
[ -n "\$OAR_BASHRC" ] && return
export PATH="/usr/lib/oar/oardodo:\$PATH"
OAR_BASHRC=yes
}
bash_oar
EOF
# Default bash sourced file in a batch job (BASH_ENV)
[ ! -f "${OARHOMEDIR}/.batch_job_bashrc" ] && cat > ${OARHOMEDIR}/.batch_job_bashrc <<EOF
#
# OAR bash environnement file for only the batch job users
#
source ~/.bashrc
EOF
touch ${OARHOMEDIR}/.bash_profile
touch ${OARHOMEDIR}/.bashrc
if ! grep -q "${OARHOMEDIR}/.bash_oar" ${OARHOMEDIR}/.bash_profile 2> /dev/null; then
echo '' >> ${OARHOMEDIR}/.bash_profile
echo "[ -f ${OARHOMEDIR}/.bash_oar ] && . ${OARHOMEDIR}/.bash_oar" >> ${OARHOMEDIR}/.bash_profile
fi
if ! grep -q "${OARHOMEDIR}/.bash_oar" ${OARHOMEDIR}/.bashrc 2> /dev/null; then
echo '' >> ${OARHOMEDIR}/.bashrc
echo "[ -f ${OARHOMEDIR}/.bash_oar ] && . ${OARHOMEDIR}/.bash_oar" >> ${OARHOMEDIR}/.bashrc
fi
set_rights ${OARHOMEDIR} 0755 ${OARUSER} ${OAROWNERGROUP}
chown ${OAROWNER}:${OAROWNERGROUP} ${OARHOMEDIR}/.bash_oar
chown ${OAROWNER}:${OAROWNERGROUP} ${OARHOMEDIR}/.bash_profile
chown ${OAROWNER}:${OAROWNERGROUP} ${OARHOMEDIR}/.bashrc
}
install_run_dir() {
# nothing to do
:
}
create_log_file() {
# Log file
touch ${LOGDIR}/oar.log && chown ${OAROWNER}:${ROOTGROUP} ${LOGDIR}/oar.log && chmod 0644 ${LOGDIR}/oar.log || true
}
common_setup() {
# Update before 2.5.2: Fix a bug causing an empty ${OARHOMEDIR}/.bash_oar
if [ -e ${OARHOMEDIR}/.bash_oar ] && [ -z "$(cat ${OARHOMEDIR}/.bash_oar)" ]; then
rm -f ${OARHOMEDIR}/.bash_oar
fi
create_oar_group
create_oar_home
create_oar_user
install_run_dir
create_log_file
mkdir -p ${OARCONFDIR}/
install_conffile \
${SHAREDIR}/oar.conf \
${OARCONFDIR}/oar.conf \
0600 ${OAROWNER}:${ROOTGROUP}
install_conffile \
${SHAREDIR}/oarnodesetting_ssh \
${OARCONFDIR}/oarnodesetting_ssh \
0755
install_conffile \
${SHAREDIR}/update_cpuset_id.sh \
${OARCONFDIR}/update_cpuset_id.sh \
0755
set_rights ${BINDIR}/oarsh 6755 ${OARDO_DEFAULTUSER} ${OARDO_DEFAULTGROUP}
set_rights ${SBINDIR}/oarnodesetting 6750 ${OARDO_DEFAULTUSER} ${OARDO_DEFAULTGROUP}
set_rights ${OARDIR}/oardodo/oardodo 6750 ${ROOTUSER} ${OAROWNERGROUP}
set_rights ${OARDIR}/oardodo 0755 ${ROOTUSER} ${OAROWNERGROUP}
}
|