Skip to content

Commit

Permalink
fix set-hosts script and setHostsFile function in lib.php
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaramadhan committed Apr 27, 2017
1 parent aa3b77b commit 1d2f9ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion kloxo/bin/kloxoversion
@@ -1 +1 @@
7.0.0.c-2017042401
7.0.0.c-2017042701
7 changes: 5 additions & 2 deletions kloxo/httpdocs/lib/html/lib.php
Expand Up @@ -7762,14 +7762,15 @@ function getKloxoType()
function setHostsFile($nolog = null)
{
log_cleanup("Add 'hostname' information to '/etc/hosts'", $nolog);

/*
$begincomment[] = "### begin - add by Kloxo-MR";
$endcomment[] = "### end - add by Kloxo-MR";
exec("hostname -s", $hnshort);
exec("hostname", $hnfull);
exec("ifconfig |grep -i 'inet addr:'|grep -v '127.0.0.1'|awk '{print $2}'|sed 's/addr\://'", $hnip);
#exec("ifconfig |grep -i 'inet addr:'|grep -v '127.0.0.1'|awk '{print $2}'|sed 's/addr\://'", $hnip);
exec("hostname -i | awk '{print $1}'", $hnip);
$content = "{$hnip[0]} {$hnfull[0]} {$hnshort[0]}\n";
Expand All @@ -7779,6 +7780,8 @@ function setHostsFile($nolog = null)
file_put_between_comments("root:root", $begincomment, $endcomment,
$begincomment[0], $endcomment[0], $hnfile, $content, $nowarning = true);
*/
exec("sh /script/set-hosts");
}

// MR -- taken http://stackoverflow.com/questions/6875913/simple-how-to-replace-all-between-with-php
Expand Down
8 changes: 4 additions & 4 deletions kloxo/pscript/set-hosts
@@ -1,10 +1,10 @@
#!/bin/sh

#if grep 'add by Kloxo-MR' /etc/hosts >/dev/null 2>&1 ; then
if [ "$(grep 'add by Kloxo-MR' /etc/hosts)" != "" ] ; then
echo "- 'add by Kloxo-MR' already exists in /etc/hosts"
exit
fi
#if [ "$(grep 'add by Kloxo-MR' /etc/hosts)" != "" ] ; then
# echo "- 'add by Kloxo-MR' already exists in /etc/hosts"
# exit
#fi

sed '/### begin/,/### end/d' /etc/hosts > /etc/hosts2

Expand Down

0 comments on commit 1d2f9ea

Please sign in to comment.