You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
3.3 KiB
140 lines
3.3 KiB
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
ONEHOME=/var/lib/one
|
|
ONE_GROUP=cloud
|
|
ONE_USER=oneadmin
|
|
|
|
# Add oneadmin user into libvirt group
|
|
if getent group libvirt >/dev/null && ! getent group libvirt | cut -f4 -d: | grep -q "\<$ONE_USER\>"; then
|
|
adduser $ONE_USER libvirt
|
|
fi
|
|
|
|
# Add oneadmin user into kvm group
|
|
if getent group kvm >/dev/null && ! getent group kvm | cut -f4 -d: | grep -q "\<$ONE_USER\>"; then
|
|
adduser $ONE_USER kvm
|
|
fi
|
|
|
|
# Backup libvirt/QEMU configuration, reconfigure for OpenNebula
|
|
if [ -e /etc/libvirt/qemu.conf ]; then
|
|
cp -f /etc/libvirt/qemu.conf "/etc/libvirt/qemu.conf.$(date +'%Y-%m-%d_%H:%M:%S')"
|
|
fi
|
|
|
|
AUGTOOL=$(augtool -A 2>/dev/null <<EOF
|
|
set /augeas/load/Libvirtd_qemu/lens Libvirtd_qemu.lns
|
|
set /augeas/load/Libvirtd_qemu/incl /etc/libvirt/qemu.conf
|
|
load
|
|
|
|
set /files/etc/libvirt/qemu.conf/user oneadmin
|
|
set /files/etc/libvirt/qemu.conf/group cloud
|
|
set /files/etc/libvirt/qemu.conf/dynamic_ownership 0
|
|
|
|
save
|
|
EOF
|
|
)
|
|
|
|
# generate generic qemu-kvm-one symlink
|
|
/usr/bin/qemu-kvm-one-gen
|
|
|
|
if [ -n "${AUGTOOL}" ] && [ -z "${AUGTOOL##*Saved *}" ]; then
|
|
systemctl try-restart libvirtd 2>/dev/null || true
|
|
fi
|
|
|
|
# # Automatically added by dh_systemd_enable/12.10ubuntu1
|
|
# if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
|
|
# if deb-systemd-helper debian-installed 'opennebula-gate-proxy.service'; then
|
|
# # This will only remove masks created by d-s-h on package removal.
|
|
# deb-systemd-helper unmask 'opennebula-gate-proxy.service' >/dev/null || true
|
|
#
|
|
# if deb-systemd-helper --quiet was-enabled 'opennebula-gate-proxy.service'; then
|
|
# # Create new symlinks, if any.
|
|
# deb-systemd-helper enable 'opennebula-gate-proxy.service' >/dev/null || true
|
|
# fi
|
|
# fi
|
|
#
|
|
# # Update the statefile to add new symlinks (if any), which need to be cleaned
|
|
# # up on purge. Also remove old symlinks.
|
|
# deb-systemd-helper update-state 'opennebula-gate-proxy.service' >/dev/null || true
|
|
# fi
|
|
# # End automatically added section
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
create_cloudgroup() {
|
|
if ! getent group $ONE_GROUP > /dev/null 2>&1; then
|
|
addgroup --system --gid $ONE_GID $ONE_GROUP
|
|
fi
|
|
}
|
|
|
|
create_oneuser() {
|
|
if ! getent passwd $ONE_USER > /dev/null 2>&1; then
|
|
adduser --system --gecos "$ONE_COMMENT" --uid $ONE_UID --ingroup $ONE_GROUP --home $ONEHOME --shell /bin/ash $ONE_USER
|
|
else
|
|
ONEHOME=`getent passwd $ONE_USER | cut -f6 -d:`
|
|
# Renable user (give him a shell)
|
|
usermod --shell /bin/ash $ONE_USER
|
|
fi
|
|
|
|
if ! getent group disk | grep "\b$ONE_USER\b" &>/dev/null; then
|
|
usermod -a -G disk $ONE_USER
|
|
fi
|
|
}
|
|
|
|
create_cloudgroup
|
|
create_oneuser
|
|
|
|
# Install ~oneadmin/.ssh/config if not present on a fresh install only
|
|
if [ ! -e "${ONEHOME}/.ssh/config" ] && [ -z "$2" ]; then
|
|
if [ ! -d "${ONEHOME}/.ssh" ]; then
|
|
mkdir -p "${ONEHOME}/.ssh"
|
|
chmod 0700 "${ONEHOME}/.ssh"
|
|
chown "$ONE_USER:$ONE_GROUP" "${ONEHOME}/.ssh"
|
|
fi
|
|
cp /usr/share/one/ssh/config "${ONEHOME}/.ssh/config"
|
|
chmod 0600 "${ONEHOME}/.ssh/config"
|
|
chown "$ONE_USER:$ONE_GROUP" "${ONEHOME}/.ssh/config"
|
|
fi
|
|
|
|
# Set permissions and owner oneadmin:cloud
|
|
for F in /var/lock/one /var/log/one /var/run/one
|
|
do
|
|
if [ ! -d "${F}" ]; then
|
|
mkdir -p "${F}"
|
|
chmod 0750 "${F}"
|
|
chown "${ONE_USER}:${ONE_GROUP}" "${F}"
|
|
fi
|
|
done
|
|
|
|
exit 0
|
|
|