diff options
author | Christian Rößler | 2013-07-02 16:49:59 +0200 |
---|---|---|
committer | Christian Rößler | 2013-07-02 16:49:59 +0200 |
commit | 83723407009b641d0700aaca213650d7f8345c6f (patch) | |
tree | df202c6fe63505558ca94535179c07cda9bad395 /remote | |
parent | + X localization libs (diff) | |
parent | add nscd link to stage32-opensuse (diff) | |
download | tm-scripts-83723407009b641d0700aaca213650d7f8345c6f.tar.gz tm-scripts-83723407009b641d0700aaca213650d7f8345c6f.tar.xz tm-scripts-83723407009b641d0700aaca213650d7f8345c6f.zip |
Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts
Diffstat (limited to 'remote')
-rw-r--r-- | remote/modules/nscd/data/etc/nscd.conf | 90 | ||||
-rw-r--r-- | remote/modules/nscd/data/etc/tmpfiles.d/nscd.conf | 1 | ||||
-rw-r--r-- | remote/modules/nscd/nscd.build | 17 | ||||
-rw-r--r-- | remote/modules/nscd/nscd.conf | 9 | ||||
l--------- | remote/modules/pam/data/etc/systemd/system/multi-user.target.wants/nscd.service | 1 | ||||
-rw-r--r-- | remote/modules/pam/data/etc/systemd/system/nscd.service | 11 | ||||
-rwxr-xr-x | remote/modules/vmchooser/data/opt/openslx/bin/clc.bash | 306 | ||||
-rwxr-xr-x | remote/modules/vmchooser/data/opt/openslx/bin/run-virt.sh | 34 | ||||
-rwxr-xr-x | remote/modules/vmchooser/data/opt/openslx/bin/xmlfilter.sh | 26 | ||||
-rwxr-xr-x[-rw-r--r--] | remote/modules/vmplayer/data/etc/openslx/vmware/run-virt.include | 9 | ||||
-rw-r--r-- | remote/rootfs/rootfs-stage32/data/etc/hosts | 8 | ||||
-rwxr-xr-x | remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script | 36 | ||||
l--------- | remote/targets/stage32-opensuse/nscd | 1 | ||||
l--------- | remote/targets/stage32/nscd | 1 |
14 files changed, 536 insertions, 14 deletions
diff --git a/remote/modules/nscd/data/etc/nscd.conf b/remote/modules/nscd/data/etc/nscd.conf new file mode 100644 index 00000000..d0a3b107 --- /dev/null +++ b/remote/modules/nscd/data/etc/nscd.conf @@ -0,0 +1,90 @@ +# +# /etc/nscd.conf +# +# An example Name Service Cache config file. This file is needed by nscd. +# +# Legal entries are: +# +# logfile <file> +# debug-level <level> +# threads <initial #threads to use> +# max-threads <maximum #threads to use> +# server-user <user to run server as instead of root> +# server-user is ignored if nscd is started with -S parameters +# stat-user <user who is allowed to request statistics> +# reload-count unlimited|<number> +# paranoia <yes|no> +# restart-interval <time in seconds> +# +# enable-cache <service> <yes|no> +# positive-time-to-live <service> <time in seconds> +# negative-time-to-live <service> <time in seconds> +# suggested-size <service> <prime number> +# check-files <service> <yes|no> +# persistent <service> <yes|no> +# shared <service> <yes|no> +# max-db-size <service> <number bytes> +# auto-propagate <service> <yes|no> +# +# Currently supported cache names (services): passwd, group, hosts, services +# + + +# logfile /var/log/nscd.log +# threads 4 +# max-threads 32 +# server-user nobody +# stat-user somebody + debug-level 0 +# reload-count 5 + paranoia no +# restart-interval 3600 + + enable-cache passwd yes + positive-time-to-live passwd 600 + negative-time-to-live passwd 20 + suggested-size passwd 211 + check-files passwd yes + persistent passwd yes + shared passwd yes + max-db-size passwd 33554432 + auto-propagate passwd yes + + enable-cache group yes + positive-time-to-live group 3600 + negative-time-to-live group 60 + suggested-size group 211 + check-files group yes + persistent group yes + shared group yes + max-db-size group 33554432 + auto-propagate group yes + + enable-cache hosts yes + positive-time-to-live hosts 3600 + negative-time-to-live hosts 20 + suggested-size hosts 211 + check-files hosts yes + persistent hosts yes + shared hosts yes + max-db-size hosts 33554432 + + enable-cache services yes + positive-time-to-live services 28800 + negative-time-to-live services 20 + suggested-size services 211 + check-files services yes + persistent services yes + shared services yes + max-db-size services 33554432 + +# netgroup caching is known-broken, so disable it in the default config, +# see: https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/1068889 + enable-cache netgroup no + positive-time-to-live netgroup 28800 + negative-time-to-live netgroup 20 + suggested-size netgroup 211 + check-files netgroup yes + persistent netgroup yes + shared netgroup yes + max-db-size netgroup 33554432 diff --git a/remote/modules/nscd/data/etc/tmpfiles.d/nscd.conf b/remote/modules/nscd/data/etc/tmpfiles.d/nscd.conf new file mode 100644 index 00000000..57c16660 --- /dev/null +++ b/remote/modules/nscd/data/etc/tmpfiles.d/nscd.conf @@ -0,0 +1 @@ +D /var/run/nscd 0755 root root diff --git a/remote/modules/nscd/nscd.build b/remote/modules/nscd/nscd.build new file mode 100644 index 00000000..bd189b66 --- /dev/null +++ b/remote/modules/nscd/nscd.build @@ -0,0 +1,17 @@ +fetch_source() { + : +} + +build() { + COPYLIST="list_dpkg_output" + [ -e "$COPYLIST" ] && rm "$COPYLIST" + + list_packet_files >> "$COPYLIST" + tarcopy "$(cat "$COPYLIST" | sort -u)" "${MODULE_BUILD_DIR}" + + return 0 +} + +post_copy() { + : +} diff --git a/remote/modules/nscd/nscd.conf b/remote/modules/nscd/nscd.conf new file mode 100644 index 00000000..3f25aea9 --- /dev/null +++ b/remote/modules/nscd/nscd.conf @@ -0,0 +1,9 @@ +REQUIRED_INSTALLED_PACKAGES=" + nscd +" +REQUIRED_CONTENT_PACKAGES=" + nscd +" +REQUIRED_BINARIES=" + nscd +" diff --git a/remote/modules/pam/data/etc/systemd/system/multi-user.target.wants/nscd.service b/remote/modules/pam/data/etc/systemd/system/multi-user.target.wants/nscd.service new file mode 120000 index 00000000..70066631 --- /dev/null +++ b/remote/modules/pam/data/etc/systemd/system/multi-user.target.wants/nscd.service @@ -0,0 +1 @@ +../nscd.service
\ No newline at end of file diff --git a/remote/modules/pam/data/etc/systemd/system/nscd.service b/remote/modules/pam/data/etc/systemd/system/nscd.service new file mode 100644 index 00000000..262bb534 --- /dev/null +++ b/remote/modules/pam/data/etc/systemd/system/nscd.service @@ -0,0 +1,11 @@ +[Unit] +Description=Name Service Cache Daemon + +[Service] +ExecStart=/usr/sbin/nscd -d +ExecStop=/usr/sbin/nscd --shutdown +Restart=always + +[Install] +WantedBy=multi-user.target +Also=nscd.socket diff --git a/remote/modules/vmchooser/data/opt/openslx/bin/clc.bash b/remote/modules/vmchooser/data/opt/openslx/bin/clc.bash new file mode 100755 index 00000000..f5c989f4 --- /dev/null +++ b/remote/modules/vmchooser/data/opt/openslx/bin/clc.bash @@ -0,0 +1,306 @@ +#!/bin/bash + +# region header + +# Copyright Torben Sickert 16.12.2012 + +# License +# This library written by Torben Sickert stand under a creative commons +# naming 3.0 unported license. +# see http://creativecommons.org/licenses/by/3.0/deed.de + +# vim: set tabstop=4 shiftwidth=4 expandtab: +# vim: foldmethod=marker foldmarker=region,endregion: + +# Dependencies: + +# vmware or virtualbox + +# Notes: + +# USE "sudo bin/vmware-vmx --new-sn JJ237-G52E2-08X0C-C3306-0WCQ1" +# To activate wmware workstation! + +# Abbreviation for "createLinkedClone". +__NAME__='clc' + +# endregion + +# Provides the main module scope. +function clc() { + +# region configuration + + # region private properties + + # region command line arguments + + local _VERBOSE='no' + local _SUPPORTED_HYPERVISOR=('VMware' 'virtualBox') + # NOTE: This value will be determined automatically. If no hypervisor + # could be detected this value will be used as default. + # The first value from supported Machines is taken as default. + local _HYPERVISOR="$_SUPPORTED_HYPERVISOR" + local _PERSISTENT_SHORT_DESCRIPTION_SUFFIX=' --persistent--' + + # endregion + + local _STANDARD_OUTPUT=/dev/null + local _ERROR_OUTPUT=/dev/null + local _BASIC_IMAGE_CONFIGURATION_FILE_PATH='' + local _TARGET_PATH='' + local _CREATE_PERSISTENT_CONFIG='no' + + # endregion + +# endregion + +# region functions + + # region command line interface + + # Prints a description about how to use this program. + function clcPrintUsageMessage() { + cat << EOF + $__NAME__ Generates a linked clone from given machine description file in + given target location. +EOF + return $? + } + + # Prints a description about how to use this program by providing examples. + function clcPrintUsageExamples() { + cat << EOF + # Getting a help message. + >>> $0 --help + + # Creating a linked clone. + >>> $0 /path/to/config.xml ~/.persistentLinkedClones/ + + # Creating a linked clone in verbose mode. + >>> $0 /path/to/config.xml ~/.persistentLinkedClones/ --verbose + + # Creating a linked clone in verbose mode with debugging output. + >>> $0 /path/to/config.xml ~/.persistentLinkedClones/ --verbose --debug + + # Creating a linked clone in verbose mode with debugging output. + >>> $0 /path/to/config.xml ~/.persistentLinkedClones/ -v -d +EOF + return $? + } + + # Prints descriptions about each available command line option. + function clcPrintCommandLineOptionDescriptions() { + # NOTE; All letters are used for short options. + cat << EOF + -h --help Shows this help message. + + -v --verbose Tells you what is going on (default: "$_VERBOSE"). + + -d --debug Gives you any output from all tools which are used + (default: "$_DEBUG"). + + -c --create-persistent-config If set an xml file for persistent openslx + boot will be created (default: "$_CREATE_PERSISTENT_CONFIG"). +EOF + return $? + } + + # Provides a help message for this module. + function clcPrintHelpMessage() { + echo -e \ + "\nUsage: $0 BASIC_IMAGE_CONFIGURATION_FILE_PATH TARGET_PATH [options]\n" && \ + clcPrintUsageMessage "$@" && \ + echo -e '\nExamples:\n' && \ + clcPrintUsageExamples "$@" && \ + echo -e '\nOption descriptions:\n' && \ + clcPrintCommandLineOptionDescriptions "$@" && \ + echo && \ + return $? + } + + # Provides the command line interface and interactive questions. + function clcCommandLineInterface() { + while true; do + case "$1" in + -h|--help) + shift + clcPrintHelpMessage "$0" + exit 0 + ;; + -v|--verbose) + shift + _VERBOSE='yes' + ;; + -d|--debug) + shift + _DEBUG='yes' + _STANDARD_OUTPUT=/dev/stdout + _ERROR_OUTPUT=/dev/stderr + ;; + -c|--create-persistent-config) + shift + _CREATE_PERSISTENT_CONFIG='yes' + ;; + + '') + shift + break 2 + ;; + *) + if [[ ! "$_BASIC_IMAGE_CONFIGURATION_FILE_PATH" ]]; then + _BASIC_IMAGE_CONFIGURATION_FILE_PATH="$1" + elif [[ ! "$_TARGET_PATH" ]]; then + _TARGET_PATH="$1" + else + clcLog 'critical' \ + "Given argument: \"$1\" is not available." '\n' + clcPrintHelpMessage "$0" + return 1 + fi + shift + ;; + esac + done + if [[ ! "$_BASIC_IMAGE_CONFIGURATION_FILE_PATH" ]] || \ + [[ ! "$_TARGET_PATH" ]]; then + clcLog 'critical' \ + "You have to provide a basic image configuration file and a destination path." + clcPrintHelpMessage "$0" + return 1 + fi + local supportedVirtualMachine + for supportedVirtualMachine in ${_SUPPORTED_HYPERVISOR[*]}; do + if [[ "$(clcGetXMLValue 'virtualMachine' | \ + grep --ignore-case "$supportedVirtualMachine")" ]]; then + _HYPERVISOR="$supportedVirtualMachine" + clcLog 'debug' "Detected \"$_HYPERVISOR\" as hypervisor." + break + fi + done + clcLog 'info' "Using \"$_HYPERVISOR\" as hypervisor." && \ + return $? + } + + # Grabs a value from currently loaded xml file. + function clcGetXMLValue() { + grep --ignore-case --only-matching "<$1 param=.*" \ + "$_BASIC_IMAGE_CONFIGURATION_FILE_PATH" | awk -F '"' '{ print $2 }' + return $? + } + + # Handles logging messages. Returns non zero and exit on log level error to + # support chaining the message into toolchain. + function clcLog() { + local loggingType='info' + local message="$1" + if [ "$2" ]; then + loggingType="$1" + message="$2" + fi + if [ "$_VERBOSE" == 'yes' ] || [ "$loggingType" == 'error' ] || \ + [ "$loggingType" == 'critical' ]; then + if [ "$3" ]; then + echo -e -n "$3" + fi + echo -e "${loggingType}: $message" + fi + if [ "$loggingType" == 'error' ]; then + exit 1 + fi + } + + # endregion + + # region tools + + # Returns the minimal vmx vmware configuration file content to create a + # snapshot. + function clcGetTemporaryVMXContent() { + cat << EOF +.encoding = "UTF-8" +config.version = "8" +virtualHW.version = "7" +ide0:0.present = "TRUE" +ide0:0.fileName = "$1" +displayName = "" +EOF + return $? + } + + # Creates a snapshot from VMware generated virtual machine. + function clcCreateVMwareSnapshot() { + local temporaryConfigurationPath="$(mktemp --directory)/" \ + 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ + local temporaryConfigurationFilePath="$(mktemp --suffix '.vmx')" \ + 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ + clcGetTemporaryVMXContent "/var/lib/virt/vmware/$(clcGetXMLValue 'image_name')" \ + 1>"$temporaryConfigurationFilePath" 2>"$_ERROR_OUTPUT" && \ + mv "$temporaryConfigurationFilePath" "$temporaryConfigurationPath" \ + 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ + clcLog "Needed files generated in \"$temporaryConfigurationPath\" generated." && \ + vmrun snapshot "$temporaryConfigurationPath"*.vmx \ + persistentUserSnapshot 1>"$_STANDARD_OUTPUT" \ + 2>"$_ERROR_OUTPUT" && \ + mv "$temporaryConfigurationPath"*.vmdk "$_TARGET_PATH" \ + 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" + local result=$? + if [[ "$_DEBUG" == 'no' ]]; then + rm --recursive "$temporaryConfigurationPath" 1>"$_STANDARD_OUTPUT" \ + 2>"$_ERROR_OUTPUT" + fi + return $result + } + + # Creates a snapshot from virtualBox generated virtual machine. + function clcCreateVirtualBoxSnapshot() { + local temporaryConfigurationPath="$(mktemp --directory)" \ + 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ + VBoxManage clonevm TODO ->(VMNAME) --snapshot base --options link \\ + --basefolder "$temporaryConfigurationPath" \ + 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ + mv "${temporaryConfigurationPath}/Snapshots/"*.vmdk "$_TARGET_PATH" \ + 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ + rm --recursive "$temporaryConfigurationPath" 1>"$_STANDARD_OUTPUT" \ + 2>"$_ERROR_OUTPUT" && \ + return $? + } + + # Creates a persistent version of given config file. + function clcCreatePersistentConfig() { + cp "$_BASIC_IMAGE_CONFIGURATION_FILE_PATH" "$_TARGET_PATH" && \ + 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ + sed --in-place --regexp-extended \ + "s/(< *short_description[^>]*param=\"[^\"]*)(\")/\\1$_PERSISTENT_SHORT_DESCRIPTION_SUFFIX\\2/g" \ + "$_TARGET_PATH" 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" + return $? + } + + # endregion + +# endregion + +# region controller + + clcCommandLineInterface "$@" || return $? + if [[ "$_CREATE_PERSISTENT_CONFIG" == 'yes' ]]; then + clcCreatePersistentConfig || \ + clcLog 'error' 'Creating persitent config failed.' + else + "clcCreate${_HYPERVISOR}Snapshot" || \ + clcLog 'error' 'Creating Linked Clone failed.' + fi + clcLog 'Program has successfully finished.' && \ + return $? + +# endregion + +} + +# region footer + +if [[ "$0" == *"${__NAME__}.bash" ]]; then + "$__NAME__" "$@" +fi + +# endregion diff --git a/remote/modules/vmchooser/data/opt/openslx/bin/run-virt.sh b/remote/modules/vmchooser/data/opt/openslx/bin/run-virt.sh index f338cd37..826bfecd 100755 --- a/remote/modules/vmchooser/data/opt/openslx/bin/run-virt.sh +++ b/remote/modules/vmchooser/data/opt/openslx/bin/run-virt.sh @@ -110,13 +110,34 @@ filecheck () ### Get XML file and dir ################################################################################ +## Added for persistent support. +diskmode='nonpersistent' +xmlfile="$1" +if [[ "$(grep --extended-regexp '< *persistent *param=".+"' "$1")" ]]; then + imageFilePath=$(grep -io '<image_name param=.*"' "$1" \ + | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }') + diskmode='persistent' && \ + # TODO path shouldn't be hardcoded. + xmlfile="/var/lib/virt/vmware/$(sed 's/-persistent$//g' <<< "$(sed 's/vmdk$/xml/g' <<< "$(basename "$imageFilePath")")")" && \ + # NOTE: We have to make sure that this folder is present to prevent + # getting an empty string by "readlink". + mkdir --parents ~/.persistentVirtualMachines/ && \ + userBranchFilePath="$(readlink --canonicalize ~/.persistentVirtualMachines/$(basename "$imageFilePath"))" + # Create linked clone if not exists. + if [ ! -f "$userBranchFilePath" ]; then + # TODO path shouldn't be hardcoded. + /opt/openslx/plugin-repo/vmchooser/clc.bash "$xmlfile" \ + "$userBranchFilePath" --debug --verbose + fi +fi +## + # absolute or relative path? -xmlfile=$1 if ls ${xmlfile} 2>/dev/null | grep '/' >/dev/null 2>&1; then xmlpath=$(dirname ${xmlfile}) xmlfile=$(basename ${xmlfile}) else - xmlpath=${path} + xmlpath=${vmchooser_xmlpath} fi # full path xmlfile="${xmlpath}/${xmlfile%.xml}.xml" @@ -170,6 +191,11 @@ writelog "VM config:" # Name of the virt image imgname=$(grep -io '<image_name param=.*"' ${xmlfile} \ | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }') +## Added for persistent support. +if [[ "$userBranchFilePath" ]]; then + imgname="$userBranchFilePath" +fi +## # Imagename /w full path if echo ${imgname} 2>/dev/null | grep -q '^/' >/dev/null 2>&1; then @@ -181,6 +207,10 @@ if echo ${imgname} 2>/dev/null | grep -q '^/' >/dev/null 2>&1; then elif echo ${xmlfile} 2>/dev/null | grep -q '^/tmp/' >/dev/null 2>&1; then vmpath=$imgname imgname=$(basename ${imgname}) +## Added for persistent support. +elif [[ "$userBranchFilePath" ]]; then + vmpath="$userBranchFilePath" +## # Else use same path as xml else imgpath=${xmlpath} diff --git a/remote/modules/vmchooser/data/opt/openslx/bin/xmlfilter.sh b/remote/modules/vmchooser/data/opt/openslx/bin/xmlfilter.sh index ded5d114..67e49d3e 100755 --- a/remote/modules/vmchooser/data/opt/openslx/bin/xmlfilter.sh +++ b/remote/modules/vmchooser/data/opt/openslx/bin/xmlfilter.sh @@ -33,18 +33,32 @@ if [ -f ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf ]; then . ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf fi -for FILE in $(find $1 -iname "*.xml"); do +function handlePersistentVM() { + if [[ "$(grep --extended-regexp \ + "<persistent param=\"(|.+:)$USER(|:.+)\"" "$1")" ]]; then + # If this virtual machine is useable as persistent version for current + # user we provide an additional persistent version. + local persistentConfigVersionFilePath="$(mktemp --directory)/$(basename "${1}-persistent")" + /opt/openslx/plugin-repo/vmchooser/clc.bash "$1" \ + "$persistentConfigVersionFilePath" --create-persistent-config && \ + echo "$persistentConfigVersionFilePath" + fi +} + +for FILE in $(find -L "$1" -iname "*.xml"); do # filter all xmls which aren't set active - if [ $(grep "<active param=.*true.*" ${FILE} | wc -l) -eq 1 ]; then - if [ -n ${vmchooser_env} ]; then + if [ $(grep "<active param=.*true.*" "$FILE" | wc -l) -eq 1 ]; then + if [ -n "${vmchooser_env}" ]; then # filter all xmls with pool-param not equal to vmchooser::env - if [ $(grep "<pools param=\"${vmchooser_env}\"" ${FILE} | wc -l) -eq 1 ];\ + if [ $(grep "<pools param=\"${vmchooser_env}\"" "$FILE" | wc -l) -eq 1 ] then - echo ${FILE}; + handlePersistentVM "$FILE" + echo "$FILE" fi else + handlePersistentVM "$FILE" # if there is no pool set, just take all available xmls - echo -e ${active} + echo "$FILE" fi fi done diff --git a/remote/modules/vmplayer/data/etc/openslx/vmware/run-virt.include b/remote/modules/vmplayer/data/etc/openslx/vmware/run-virt.include index 9b0fea91..e50ed992 100644..100755 --- a/remote/modules/vmplayer/data/etc/openslx/vmware/run-virt.include +++ b/remote/modules/vmplayer/data/etc/openslx/vmware/run-virt.include @@ -117,9 +117,8 @@ MemAllowAutoScaleDown = "FALSE" MemTrimRate = "-1" # ide-disks -ide0:0.present = "$ide" -ide0:0.fileName = "$diskfile" -ide0:0.mode = "independent-nonpersistent" + +ide0:0.mode = \"independent-${diskmode}\" ide1:0.present = "$cdrom0" ide1:0.autodetect = "TRUE" ide1:0.fileName = "auto detect" @@ -134,7 +133,7 @@ scsi0.present = "$scsi" scsi0:0.present = "$scsi" scsi0:0.fileName = "$diskfile" scsi0.virtualDev = "$hddrv" -scsi0:0.mode = "independent-nonpersistent" +scsi0:0.mode = \"independent-${diskmode}\" # floppies floppy0.present = "$floppy0" @@ -447,7 +446,7 @@ cp "/etc/openslx/vmware/nvram" "$confdir/nvram" 2>/dev/null # log script information writelog "# File created by $0 (VMversion ${vmversion})\n# on $(date)\n" -writelog "Starting with non-persistent mode ...\n" +writelog "Starting with ${diskmode} mode ...\n" # write all results to logfile # log disksetup diff --git a/remote/rootfs/rootfs-stage32/data/etc/hosts b/remote/rootfs/rootfs-stage32/data/etc/hosts new file mode 100644 index 00000000..631cf753 --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/etc/hosts @@ -0,0 +1,8 @@ +127.0.0.1 localhost + +# The following lines are desirable for IPv6 capable hosts +::1 ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff00::0 ip6-mcastprefix +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script index 08d59eba..1bbf6e80 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script @@ -29,6 +29,14 @@ rebuild_resolv_conf () { sort -u /run/udhcpc/*.resolv > "$RESOLV_CONF" } +escape_search() { + echo "$@" | sed -e 's/[]\/()$*.^|[]/\\&/g' +} + +escape_replace() { + echo "$@" | sed -e 's/[\/&]/\\&/g' +} + case "$1" in bound|renew) ip addr add "$ip/$(ipcalc -s -p $ip $subnet|sed s/.*=//)" dev "$interface" @@ -39,7 +47,7 @@ case "$1" in # Update resolver configuration file CONF="" if [ -n "$domain" ]; then - printf -v CONF "domain $domain\n" + printf -v CONF "domain $domain\nsearch $domain\n" elif [ -n "$SLX_NET_DOMAIN" ]; then printf -v CONF "domain $SLX_NET_DOMAIN\nsearch $SLX_NET_DOMAIN\n" fi @@ -81,6 +89,32 @@ case "$1" in fi fi + # Hostname in /etc/hosts + touch /etc/hosts + if [ -n "$dns_host" ]; then + short="${dns_host%%.*}" + [ "x$short" = "x$dns_host" ] && short="" + sed -i -r "s/\s$(escape_search "$dns_host")(\s|$)/ /g" /etc/hosts + [ -n "$short" ] && sed -i -r "s/\s$(escape_search "$short")(\s|$)/ /g" /etc/hosts + if grep -q -E "^$ip\s" /etc/hosts; then + sed -i "s/^$(escape_search "$ip")\s/$(escape_replace "$ip $dns_host $short ")/g" /etc/hosts + else + echo "$ip $dns_host $short" >> /etc/hosts + fi + fi + if [ -n "$hostname" -a "x$hostname" != "x$dns_host" ]; then + short="${hostname%%.*}" + [ "x$short" = "x$hostname" ] && short="" + sed -i -r "s/\s$(escape_search "$hostname")(\s|$)/ /g" /etc/hosts + [ -n "$short" ] && sed -i -r "s/\s$(escape_search "$short")(\s|$)/ /g" /etc/hosts + if grep -q -E "^$ip\s" /etc/hosts; then + sed -i "s/^$(escape_search "$ip")\s/$(escape_replace "$ip $hostname $short ")/g" /etc/hosts + else + echo "$ip $hostname $short" >> /etc/hosts + fi + fi + sed -i -r '/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s*$/d' /etc/hosts + # We consider the network setup to be complete if an interface is being configured that # has a default route and some dns servers set. if [ -n "$router" ] && [ -n "$dns" ] && [ ! -e "/run/udhcpc/network-ready" ]; then diff --git a/remote/targets/stage32-opensuse/nscd b/remote/targets/stage32-opensuse/nscd new file mode 120000 index 00000000..d7e411d2 --- /dev/null +++ b/remote/targets/stage32-opensuse/nscd @@ -0,0 +1 @@ +../../modules/nscd
\ No newline at end of file diff --git a/remote/targets/stage32/nscd b/remote/targets/stage32/nscd new file mode 120000 index 00000000..d7e411d2 --- /dev/null +++ b/remote/targets/stage32/nscd @@ -0,0 +1 @@ +../../modules/nscd
\ No newline at end of file |