Script pathname ($0) is no longer important, just currentdir and its basename
[enbrace.git] / enbrace.bash
index b2924c5..3abb69b 100755 (executable)
@@ -3,6 +3,13 @@
 # $Id$
 #
 # cd;echo 'default login anonymous password short@' >~/.netrc;echo -e 'bi\nhash\ncd pub/priv/short/enbrace\nget enbrace.bash\nquit'|ftp vellum.cz;/usr/local/bin/bash enbrace.bash
+#
+# Patch multi-application liable files:
+# [cs_CZ] Soubory citlive na vicenasobnou aplikaci patche:
+#      /etc/rc.local
+#      /root/.login
+#      /etc/inetd.conf
+#      /etc/crontab
 
 function fatal
 {
@@ -10,10 +17,10 @@ function fatal
        exit 1
 }
 
-if [ "$USER" != "root"         ];then fatal "This script must be run as 'root'"               ;fi
-if [ "$PWD"  != "/root"        ];then fatal "This script must be run from directory '/root'"  ;fi
-if [ "$0"    != "enbrace.bash" ];then fatal "This script must be named 'enbrace.bash'"        ;fi
-if [ -e "enbrace"              ];then fatal "'/root/enbrace' directory already exists"        ;fi
+if [ "$USER" != "root"                   ];then fatal "This script must be run as 'root'"               ;fi
+if [ "$PWD"  != "/root"                  ];then fatal "This script must be run from directory '/root'"  ;fi
+if [ "`basename "$0"`" != "enbrace.bash" ];then fatal "This script must be named 'enbrace.bash'"        ;fi
+if [ -e "enbrace"                        ];then fatal "'/root/enbrace' directory already exists"        ;fi
 
 function ftpget
 {
@@ -24,6 +31,7 @@ default
                prom
                bi
                hash
+               pass
 
 EOF
        if [ $# != 1 ];then fatal "ftpget(): (arg1=URL) required!";fi
@@ -36,7 +44,7 @@ EOF
                echo -n "Using already downloaded file \"$1\": ";ls -l "$file"
                return 0
                fi
-       echo -e "cd \"$dir\"\\nget \"$file\"\\nquit"|ftp "$host"
+       echo -e "cd \"$dir\"\\nget \"$file\"\\nquit"|ftp -v "$host"
        return 0
 }
 
@@ -45,8 +53,8 @@ set -ex
 (
 
 # Config
-       openssl="ftp://ftp.openssl.org/source/openssl-0.9.6b.tar.gz"
-       openssh="ftp://ftp1.se.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-3.0p1.tar.gz"
+       openssl="ftp://ftp.openssl.org/source/openssl-0.9.6c.tar.gz"
+       openssh="ftp://ftp1.se.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-3.1p1.tar.gz"
 
 # Init
        chmod +x enbrace.bash
@@ -163,10 +171,46 @@ EOF
 +# Jan Kolar <jan.kolar@jklabs.cz> /Lace
 +*/30  *       *       *       *       root    /usr/sbin/sendmail -q
 EOF
+       cat >openssh-3.1p1-i386-unknown-freebsd2.2.5.diff <<EOF
+--- configure.ac-orig  Thu Apr  4 00:35:36 2002
++++ configure.ac       Thu Apr  4 00:35:45 2002
+@@ -138,6 +138,7 @@
+       ;;
+ *-*-freebsd*)
+       check_for_libcrypt_later=1
++      AC_DEFINE(HAVE_BOGUS_SYS_QUEUE_H)
+       ;;
+ *-next-*)
+       conf_lastlog_location="/usr/adm/lastlog"
+--- configure-orig     Thu Apr  4 00:35:55 2002
++++ configure  Thu Apr  4 00:40:37 2002
+@@ -3568,6 +3568,10 @@
+       ;;
+ *-*-freebsd*)
+       check_for_libcrypt_later=1
++      cat >>confdefs.h <<\_ACEOF
++#define HAVE_BOGUS_SYS_QUEUE_H 1
++_ACEOF
++
+       ;;
+ *-next-*)
+       conf_lastlog_location="/usr/adm/lastlog"
+--- defines.h-orig     Wed Feb 27 03:40:49 2002
++++ defines.h  Thu Apr  4 01:00:56 2002
+@@ -146,7 +146,7 @@
+ including rpc/rpc.h breaks Solaris 6
+ */
+ #ifndef INADDR_LOOPBACK
+-#define INADDR_LOOPBACK ((ulong)0x7f000001)
++#define INADDR_LOOPBACK ((unsigned long)0x7f000001)
+ #endif
+ /* Types */
+EOF
 
 # Sendmail
        (cd /
-               patch -sEp0 </root/enbrace/sendmail.diff
+               patch -sENp0 </root/enbrace/sendmail.diff
                )
        set +e;killall sendmail;set -e
 
@@ -186,6 +230,7 @@ EOF
        ftpget "$openssh"
        tar xzf "$file"
        (cd "$base"
+               patch -sENp0 <../openssh-3.1p1-i386-unknown-freebsd2.2.5.diff
                #make clean
                ./configure --with-ipv4-default \
                                --with-default-path="/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin" \
@@ -193,18 +238,18 @@ EOF
                make 2>&1|tee errs2
                make install 2>&1|tee errs3
                )
-       patch /etc/rc.local <rc.local.diff
+       patch -N /etc/rc.local <rc.local.diff
        /usr/local/sbin/sshd
 
 # Apache
-       patch /usr/local/etc/httpd/conf/httpd.conf <httpd.conf.diff
+       patch -N /usr/local/etc/httpd/conf/httpd.conf <httpd.conf.diff
        # We need to temporarily disable error checking as killall(1) MAY fail (why?)
        set +e;killall -HUP httpd;set -e
 
 # Root rcs
-       patch /root/.cshrc <root-cshrc.diff
-       patch /root/.login <root-login.diff
-       patch /root/.forward <root-mail.diff
+       patch -N /root/.cshrc <root-cshrc.diff
+       patch -N /root/.login <root-login.diff
+       patch -N /root/.forward <root-mail.diff
 
 # Sendmail-post
        set +e;killall -HUP inetd;set -e
@@ -216,4 +261,5 @@ EOF
 
 # Finalization
        echo "$0: success."
-) 2>&1|tee enbrace.`date '+%Y-%m-%H-%H:%M:%S'`.log
+) 2>&1|tee enbrace.`date '+%Y-%m-%d-%H:%M:%S'`.log
+