summaryrefslogtreecommitdiffstats
path: root/remote/includes
diff options
context:
space:
mode:
authorSimon Rettberg2014-07-04 14:46:20 +0200
committerSimon Rettberg2014-07-04 14:46:20 +0200
commitd1f5aedd76df437a08f3283fa00bc8a9dab7fa2b (patch)
tree8c046eeaf8e874b479b95964b2bf410365cff438 /remote/includes
parentremove hardcoded /bin/rm call. Relative calls work in services files (diff)
downloadtm-scripts-d1f5aedd76df437a08f3283fa00bc8a9dab7fa2b.tar.gz
tm-scripts-d1f5aedd76df437a08f3283fa00bc8a9dab7fa2b.tar.xz
tm-scripts-d1f5aedd76df437a08f3283fa00bc8a9dab7fa2b.zip
"Fedora Support", step 1 ->
Several changes: 1) Make sure /bin /sbin /lib and /lib64 are ALWAYS symlinks to /usr/XXX, no matter what the current distribution does. 2) Make sure nobody and nogroup exist. 3) Fix various modules making assumptions that are not true on every distro. 4) Add symlinks to kdm module since fedora is looking for kdmrc in yet another spot. 5) Add detection of fedora, support its package manager What still breaks: dnbd3 Other distros might not work now, they need adaption to changed logic in some modules.
Diffstat (limited to 'remote/includes')
-rw-r--r--remote/includes/distribution.inc2
-rw-r--r--remote/includes/kernel.inc11
-rw-r--r--remote/includes/packagemanager.inc16
-rw-r--r--remote/includes/system.inc1
-rw-r--r--remote/includes/useradd.inc4
5 files changed, 20 insertions, 14 deletions
diff --git a/remote/includes/distribution.inc b/remote/includes/distribution.inc
index 7a7be738..137da7ef 100644
--- a/remote/includes/distribution.inc
+++ b/remote/includes/distribution.inc
@@ -18,7 +18,7 @@ detect_distribution () {
PACKET_MANAGER="zypper"
PACKET_HANDLER="rpm"
;;
- scientific)
+ scientific|fedora)
PACKET_MANAGER="yum"
PACKET_HANDLER="rpm"
;;
diff --git a/remote/includes/kernel.inc b/remote/includes/kernel.inc
index dc7f7f12..3acb1810 100644
--- a/remote/includes/kernel.inc
+++ b/remote/includes/kernel.inc
@@ -28,9 +28,12 @@ get_kernel_version () {
# set empty SYS_UTS_RELEASE and SYS_KERNEL
SYS_UTS_RELEASE="(unknown)"
SYS_KERNEL="$(echo "$SYS_UTS_RELEASE" | grep -o -E '^[0-9\.]+')"
+ # System kernel version
+ SYSTEM_KERNEL_LONG=$(uname -r)
+ SYSTEM_KERNEL_SHORT=$(grep -o -E '^[0-9\.]+' <<<$SYSTEM_KERNEL_LONG)
}
-check_kernel_base_dir() {
+check_kernel_base_dir () {
# check if KERNEL_BASE_DIR was set, if not we don't know
# whether kernel-openslx or kernel-system has been built
@@ -46,7 +49,7 @@ check_kernel_base_dir() {
}
-copy_kernel_modules() {
+copy_kernel_modules () {
pinfo "Copying kernel modules for kernel ${KERNEL_CURRENT_VERSION}..."
[ -z "${REQUIRED_KERNEL_MODULES}" ] && perror "REQUIRED_KERNEL_MODULES is empty. Check your config file."
[ -z "${KERNEL_HEADERS_PATH}" ] && perror "KERNEL_HEADERS_PATH is empty. Kernel headers appears to be missing."
@@ -128,7 +131,7 @@ copy_kernel_modules() {
cd "${OLD_DIR}" || perror "Could not cd back to ${OLD_DIR}."
}
-copy_firmware() {
+copy_firmware () {
pinfo "Copying firmware for kernel ${KERNEL_CURRENT_VERSION}..."
[ -z "${REQUIRED_FIRMWARE}" ] && perror "REQUIRED_FIRMWARE is empty. Check your config file."
@@ -205,7 +208,7 @@ copy_firmware() {
cd "${OLD_DIR}" || perror "Could not cd back to ${OLD_DIR}."
}
-copy_kernel() {
+copy_kernel () {
check_kernel_base_dir
local TOOL_STR="$TOOL_STR copy_kernel:"
diff --git a/remote/includes/packagemanager.inc b/remote/includes/packagemanager.inc
index 66013807..63acf270 100644
--- a/remote/includes/packagemanager.inc
+++ b/remote/includes/packagemanager.inc
@@ -98,34 +98,36 @@ install_packages() {
[ $# -eq 0 ] && perror "Sanity check failed: no argument given to install_package"
local PACKAGE_LIST="$@"
local INSTALLED_PACKAGES=""
+ local LRET=""
for PKG in ${PACKAGE_LIST}; do
# check if installed:
# this is done mainly for performance reasons, even though
- # reinstalling all packages is a valid possibility too...
+ # reinstalling all packages is a valid possibility too...
if [ "x$PACKET_HANDLER" == "xdpkg" ]; then
dpkg -l ${PKG} > /dev/null 2>&1
+ LRET=$?
elif [ "x$PACKET_HANDLER" == "xrpm" ]; then
- rpm -ql ${PKG} > /dev/null 2>&1
+ rpm -ql "${PKG}" > /dev/null 2>&1
+ LRET=$?
else
perror "No packet manager / handler determined, this should not happen!"
fi
- local LRET=$?
if [ "x$LRET" == "x0" ]; then
# check if it is completly installed, not just leftover configuration files
if [ "x$PACKET_HANDLER" == "xdpkg" ]; then
- local INSTALL_STATUS=$(dpkg -l $PKG | grep $PKG | cut -c1-2)
+ local INSTALL_STATUS=$(dpkg -l "${PKG}" | grep "${PKG}" | cut -c1-2)
if [[ $INSTALL_STATUS != "ii" ]]; then
pinfo "$PKG is either missing or a meta-package! Installing it to be sure..."
- install_package $PKG
+ install_package "${PKG}"
else
# package installed
- pdebug "$PKG installed!"
+ pdebug "${PKG} installed!"
fi
elif [ "x$PACKET_HANDLER" == "xrpm" ]; then
# TODO: blindly install again for now
- install_package $PKG
+ rpm -q "${PKG}" >/dev/null 2>&1 || install_package "${PKG}"
fi
else
# package not installed
diff --git a/remote/includes/system.inc b/remote/includes/system.inc
index bcdaed23..17a80761 100644
--- a/remote/includes/system.inc
+++ b/remote/includes/system.inc
@@ -21,6 +21,7 @@ if [ "$(uname -m)x" = "x86_64x" ]; then
case $SYS_DISTRIBUTION in
ubuntu | debian) LIB64="lib" ;;
opensuse) LIB64="lib64" ;;
+ fedora) LIB64="lib64" ;;
*) perror "Cannot set LIB64, SYS_DISTRIBUTION: $SYS_DISTRIBUTION unknown!" ;;
esac
AMD64_I386=amd64
diff --git a/remote/includes/useradd.inc b/remote/includes/useradd.inc
index 352da606..29a9c39a 100644
--- a/remote/includes/useradd.inc
+++ b/remote/includes/useradd.inc
@@ -16,7 +16,7 @@
. "${ROOT_DIR}/helper/string.inc"
-NAME_REGEX='^[a-z][-a-z0-9]*$'
+declare -r NAME_REGEX='^[a-z][-a-z0-9]*$'
# Generate a UID for a given USERNAME. Return existing UID if possible, generate new one otherwise
generate_uid()
@@ -150,7 +150,7 @@ add_user() {
pinfo "Created user $USER"
elif [ "$PASSWORD" != "*" ]; then
# update user's password
- sed -i -r "s#^${USER}:[^:]*:(.*)\$#${USER}:${PASSWORD}:\1#g" "${_SHADOW}"
+ sed -i -r "s#^${USER}:[^:]*:(.*)\$"'#'"${USER}:${PASSWORD}:\1#g" "${_SHADOW}"
pinfo "Updated password of $USER"
fi
[ -z "${_GID}" ] && pinfo "Created group $GROUP" && echo "${GROUP}:x:${GROUPID}:" >> "${_GROUP}"