diff options
author | Ramón M. Gómez <ramongomez@us.es> | 2020-02-25 11:08:21 +0100 |
---|---|---|
committer | Ramón M. Gómez <ramongomez@us.es> | 2020-02-25 11:08:21 +0100 |
commit | 995b512765f380d164b2b3959188d6b9e856434b (patch) | |
tree | a12bd6f50631f01c4a8b257debf13260fb87071a /server/bin/setserveraddr | |
parent | 81b2ea1a64279d9d90af8028369b034a04fb4545 (diff) |
#957: `setserveraddr` uses the new global functions.
Diffstat (limited to 'server/bin/setserveraddr')
-rwxr-xr-x | server/bin/setserveraddr | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/server/bin/setserveraddr b/server/bin/setserveraddr index 21b884c2..18ee8c6a 100755 --- a/server/bin/setserveraddr +++ b/server/bin/setserveraddr @@ -3,9 +3,9 @@ #/** #@file setserveraddr #@brief Assign default IP address to OpenGnsys services. -#@usage setserveraddr {str_ipaddress | str_netiface} -#@param str_ipaddress IP address assigned to a network interface -#@param str_netiface network interface name defined by the operating system +#@usage setserveraddr { IPAddress | NetIface } +#@param IPAddress IP address assigned to a network interface +#@param NetIface network interface name defined by the operating system #@version Initial version. #@author Ramón M. Gómez - ETSII Univ. Sevilla #@date 2011-01-25 @@ -19,14 +19,16 @@ # Variables. -PROG="$(basename "$0")" -OPENGNSYS=/opt/opengnsys +OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"} PXEDIRS="$OPENGNSYS/tftpboot/menu.lst $OPENGNSYS/tftpboot/grub" DEFAULTFILE=/etc/default/opengnsys # Functions. -source $OPENGNSYS/lib/ogfunctions.sh +source $OPENGNSYS/lib/ogfunctions.sh || exit 1 +# Show help or version number. +[ "$*" == "help" ] && help +[ "$*" == "version" ] && version # Checking parameters. [ "$USER" != "root" ] && raiseError access "Need to be root" [ $# -ne 1 ] && raiseError usage @@ -34,8 +36,6 @@ source $OPENGNSYS/lib/ogfunctions.sh for f in $OPENGNSYS/{etc/{ogAdmServer,ogAdmRepo,ogAdmAgent}.cfg,www/controlacceso.php,client/etc/ogAdmClient.cfg}; do [ -w $f ] || raiseError access "Cannot write to file: $f" done -# Show help message. -[ "$1" == "help" ] && help # Detecting network interfaces. DEVICES=$(ip -o link show up | awk -F: '$2!~/lo/ {print $2}') @@ -55,8 +55,7 @@ if [ -n "$SERVERIP" ]; then [ "${ANSWER,,}" != "y" ] && raiseError cancel "Do nothing" # Temporary files. tmpfile=$(mktemp /tmp/og.XXXXX) - MYCNF=$(mktemp /tmp/.my.cnf.XXXXX) - trap "rm -f $tmpfile $MYCNF" 1 2 3 6 9 15 + trap "rm -f $tmpfile" 1 2 3 6 9 15 # Checking whether the DHCP settings need to be changed. CHANGE=0 @@ -112,14 +111,8 @@ if [ -n "$SERVERIP" ]; then source $DEFAULTFILE # If OpenGnsys Server is active, updating the database. if [ "$RUN_OGADMSERVER" == "yes" ]; then - # Creating credentials file. - cat << EOT > $MYCNF -[client] -user=$USUARIO -password=$PASSWORD -EOT # Updating IP addresses and menu URLs. - mysql --defaults-extra-file=$MYCNF -D "$CATALOG" << EOT + dbexec " UPDATE entornos SET ipserveradm='$SERVERIP' WHERE identorno=1; @@ -128,8 +121,7 @@ UPDATE repositorios WHERE ip='$OLDSERVERIP'; UPDATE menus SET htmlmenupub = REPLACE(htmlmenupub, '$OLDSERVERIP', '$SERVERIP'), - htmlmenupri = REPLACE(htmlmenupri, '$OLDSERVERIP', '$SERVERIP'); -EOT + htmlmenupri = REPLACE(htmlmenupri, '$OLDSERVERIP', '$SERVERIP');" # Updating all PXE files. find $PXEDIRS -name "01-*" -exec sed -i -e "s/$OLDSERVERIP/$SERVERIP/g" {} \; fi @@ -155,5 +147,5 @@ else fi # Removing temporary files. -rm -f $tmpfile $MYCNF +rm -f $tmpfile |