From 50310b0e4513ee3fcce67351ae61e8fff851130e Mon Sep 17 00:00:00 2001 From: M.Gergo Date: Fri, 6 Jul 2018 11:13:06 +0200 Subject: Mappák átnevezve: mayor --> mayor-mod; mayor-installer --> mayor-installer-mod; mayor-installer-fcgi --> mayor-installer-fcgi-mod --- .../fcgi_install.d/01createhome.sh | 73 +++ .../fcgi_install.d/05checkdeb.sh | 106 ++++ .../fcgi_install.d/10getsource.sh | 79 +++ .../fcgi_install.d/15createconfig.sh | 46 ++ mayor-installer-fcgi-mod/fcgi_install.d/20mysql.sh | 34 ++ .../fcgi_install.d/25apache.sh | 254 ++++++++ mayor-installer-fcgi-mod/fcgi_install.d/30php.sh | 35 ++ .../fcgi_install.d/35createdatabases.sh | 129 ++++ .../fcgi_install.d/40binary.sh | 52 ++ .../fcgi_install.d/45intezmeny.sh | 70 +++ .../fcgi_install.d/50linker.sh | 59 ++ mayor-installer-fcgi-mod/fcgi_install.d/55tex.sh | 20 + .../fcgi_install.d/60portal.sh | 119 ++++ mayor-installer-fcgi-mod/fcgi_install.d/90chown.sh | 30 + mayor-installer-fcgi-mod/fcgi_install.d/99end.sh | 7 + mayor-installer-fcgi-mod/install.d/05checkdeb.sh | 106 ++++ mayor-installer-fcgi-mod/install.d/10getsource.sh | 79 +++ .../install.d/15createconfig.sh | 43 ++ mayor-installer-fcgi-mod/install.d/20mysql.sh | 28 + mayor-installer-fcgi-mod/install.d/25apache.sh | 67 +++ mayor-installer-fcgi-mod/install.d/30php.sh | 29 + .../install.d/35createdatabases.sh | 132 ++++ mayor-installer-fcgi-mod/install.d/40binary.sh | 49 ++ mayor-installer-fcgi-mod/install.d/45intezmeny.sh | 70 +++ mayor-installer-fcgi-mod/install.d/50linker.sh | 58 ++ mayor-installer-fcgi-mod/install.d/55tex.sh | 20 + mayor-installer-fcgi-mod/install.d/60portal.sh | 119 ++++ mayor-installer-fcgi-mod/log/mayor-installer.rev | 1 + mayor-installer-fcgi-mod/setup | 48 ++ .../fcgi_install.d/01createhome.sh | 73 --- mayor-installer-fcgi/fcgi_install.d/05checkdeb.sh | 106 ---- mayor-installer-fcgi/fcgi_install.d/10getsource.sh | 79 --- .../fcgi_install.d/15createconfig.sh | 46 -- mayor-installer-fcgi/fcgi_install.d/20mysql.sh | 34 -- mayor-installer-fcgi/fcgi_install.d/25apache.sh | 254 -------- mayor-installer-fcgi/fcgi_install.d/30php.sh | 35 -- .../fcgi_install.d/35createdatabases.sh | 129 ---- mayor-installer-fcgi/fcgi_install.d/40binary.sh | 52 -- mayor-installer-fcgi/fcgi_install.d/45intezmeny.sh | 70 --- mayor-installer-fcgi/fcgi_install.d/50linker.sh | 59 -- mayor-installer-fcgi/fcgi_install.d/55tex.sh | 20 - mayor-installer-fcgi/fcgi_install.d/60portal.sh | 119 ---- mayor-installer-fcgi/fcgi_install.d/90chown.sh | 30 - mayor-installer-fcgi/fcgi_install.d/99end.sh | 7 - mayor-installer-fcgi/install.d/05checkdeb.sh | 106 ---- mayor-installer-fcgi/install.d/10getsource.sh | 79 --- mayor-installer-fcgi/install.d/15createconfig.sh | 43 -- mayor-installer-fcgi/install.d/20mysql.sh | 28 - mayor-installer-fcgi/install.d/25apache.sh | 67 --- mayor-installer-fcgi/install.d/30php.sh | 29 - .../install.d/35createdatabases.sh | 132 ---- mayor-installer-fcgi/install.d/40binary.sh | 49 -- mayor-installer-fcgi/install.d/45intezmeny.sh | 70 --- mayor-installer-fcgi/install.d/50linker.sh | 58 -- mayor-installer-fcgi/install.d/55tex.sh | 20 - mayor-installer-fcgi/install.d/60portal.sh | 119 ---- mayor-installer-fcgi/log/mayor-installer.rev | 1 - mayor-installer-fcgi/setup | 48 -- mayor-installer-mod/install.d/05checkdeb.sh | 106 ++++ mayor-installer-mod/install.d/10getsource.sh | 79 +++ mayor-installer-mod/install.d/15createconfig.sh | 43 ++ mayor-installer-mod/install.d/20mysql.sh | 28 + mayor-installer-mod/install.d/25apache.sh | 67 +++ mayor-installer-mod/install.d/30php.sh | 40 ++ mayor-installer-mod/install.d/35createdatabases.sh | 132 ++++ mayor-installer-mod/install.d/40binary.sh | 49 ++ mayor-installer-mod/install.d/45intezmeny.sh | 70 +++ mayor-installer-mod/install.d/50linker.sh | 58 ++ mayor-installer-mod/install.d/55tex.sh | 20 + mayor-installer-mod/install.d/60portal.sh | 119 ++++ mayor-installer-mod/log/mayor-installer.rev | 1 + mayor-installer-mod/setup | 34 ++ mayor-installer/install.d/05checkdeb.sh | 106 ---- mayor-installer/install.d/10getsource.sh | 79 --- mayor-installer/install.d/15createconfig.sh | 43 -- mayor-installer/install.d/20mysql.sh | 28 - mayor-installer/install.d/25apache.sh | 67 --- mayor-installer/install.d/30php.sh | 40 -- mayor-installer/install.d/35createdatabases.sh | 132 ---- mayor-installer/install.d/40binary.sh | 49 -- mayor-installer/install.d/45intezmeny.sh | 70 --- mayor-installer/install.d/50linker.sh | 58 -- mayor-installer/install.d/55tex.sh | 20 - mayor-installer/install.d/60portal.sh | 119 ---- mayor-installer/log/mayor-installer.rev | 1 - mayor-installer/setup | 34 -- mayor-mod/bin/backup.sh | 317 ++++++++++ mayor-mod/bin/crypt-backup.sh | 144 +++++ mayor-mod/bin/decrypt-backup.sh | 138 +++++ mayor-mod/bin/etc/cron.daily/mayor | 13 + mayor-mod/bin/help.sh | 47 ++ mayor-mod/bin/lock.sh | 42 ++ mayor-mod/bin/mayor | 74 +++ mayor-mod/bin/remote-backup.sh | 170 ++++++ mayor-mod/bin/restore.sh | 257 ++++++++ mayor-mod/bin/sbin/eNaploBackup.sh | 95 +++ mayor-mod/bin/sbin/eNaploRestore.sh | 82 +++ mayor-mod/bin/sbin/update.sh | 33 + mayor-mod/bin/tex2pdf.sh | 24 + mayor-mod/bin/unlock.sh | 49 ++ mayor-mod/bin/update.sh | 227 +++++++ mayor-mod/bin/xetex2pdf.sh | 36 ++ mayor-mod/update/processUpdateScripts.sh | 267 +++++++++ mayor-mod/update/processUpdateScripts.sh.mod.txt | 183 ++++++ mayor-mod/update/processUpdateScripts.sh.orig | 259 ++++++++ mayor-mod/www/include/modules/naplo/share/file.php | 662 +++++++++++++++++++++ mayor/bin/backup.sh | 317 ---------- mayor/bin/crypt-backup.sh | 144 ----- mayor/bin/decrypt-backup.sh | 138 ----- mayor/bin/etc/cron.daily/mayor | 13 - mayor/bin/help.sh | 47 -- mayor/bin/lock.sh | 42 -- mayor/bin/mayor | 74 --- mayor/bin/remote-backup.sh | 170 ------ mayor/bin/restore.sh | 257 -------- mayor/bin/sbin/eNaploBackup.sh | 95 --- mayor/bin/sbin/eNaploRestore.sh | 82 --- mayor/bin/sbin/update.sh | 33 - mayor/bin/tex2pdf.sh | 24 - mayor/bin/unlock.sh | 49 -- mayor/bin/update.sh | 227 ------- mayor/bin/xetex2pdf.sh | 36 -- mayor/update/processUpdateScripts.sh | 267 --------- mayor/update/processUpdateScripts.sh.mod.txt | 183 ------ mayor/update/processUpdateScripts.sh.orig | 259 -------- mayor/www/include/modules/naplo/share/file.php | 662 --------------------- 126 files changed, 5927 insertions(+), 5927 deletions(-) create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/01createhome.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/05checkdeb.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/10getsource.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/15createconfig.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/20mysql.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/25apache.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/30php.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/35createdatabases.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/40binary.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/45intezmeny.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/50linker.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/55tex.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/60portal.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/90chown.sh create mode 100755 mayor-installer-fcgi-mod/fcgi_install.d/99end.sh create mode 100755 mayor-installer-fcgi-mod/install.d/05checkdeb.sh create mode 100755 mayor-installer-fcgi-mod/install.d/10getsource.sh create mode 100755 mayor-installer-fcgi-mod/install.d/15createconfig.sh create mode 100755 mayor-installer-fcgi-mod/install.d/20mysql.sh create mode 100755 mayor-installer-fcgi-mod/install.d/25apache.sh create mode 100755 mayor-installer-fcgi-mod/install.d/30php.sh create mode 100755 mayor-installer-fcgi-mod/install.d/35createdatabases.sh create mode 100755 mayor-installer-fcgi-mod/install.d/40binary.sh create mode 100755 mayor-installer-fcgi-mod/install.d/45intezmeny.sh create mode 100755 mayor-installer-fcgi-mod/install.d/50linker.sh create mode 100755 mayor-installer-fcgi-mod/install.d/55tex.sh create mode 100755 mayor-installer-fcgi-mod/install.d/60portal.sh create mode 100644 mayor-installer-fcgi-mod/log/mayor-installer.rev create mode 100755 mayor-installer-fcgi-mod/setup delete mode 100755 mayor-installer-fcgi/fcgi_install.d/01createhome.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/05checkdeb.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/10getsource.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/15createconfig.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/20mysql.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/25apache.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/30php.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/35createdatabases.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/40binary.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/45intezmeny.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/50linker.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/55tex.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/60portal.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/90chown.sh delete mode 100755 mayor-installer-fcgi/fcgi_install.d/99end.sh delete mode 100755 mayor-installer-fcgi/install.d/05checkdeb.sh delete mode 100755 mayor-installer-fcgi/install.d/10getsource.sh delete mode 100755 mayor-installer-fcgi/install.d/15createconfig.sh delete mode 100755 mayor-installer-fcgi/install.d/20mysql.sh delete mode 100755 mayor-installer-fcgi/install.d/25apache.sh delete mode 100755 mayor-installer-fcgi/install.d/30php.sh delete mode 100755 mayor-installer-fcgi/install.d/35createdatabases.sh delete mode 100755 mayor-installer-fcgi/install.d/40binary.sh delete mode 100755 mayor-installer-fcgi/install.d/45intezmeny.sh delete mode 100755 mayor-installer-fcgi/install.d/50linker.sh delete mode 100755 mayor-installer-fcgi/install.d/55tex.sh delete mode 100755 mayor-installer-fcgi/install.d/60portal.sh delete mode 100644 mayor-installer-fcgi/log/mayor-installer.rev delete mode 100755 mayor-installer-fcgi/setup create mode 100755 mayor-installer-mod/install.d/05checkdeb.sh create mode 100755 mayor-installer-mod/install.d/10getsource.sh create mode 100755 mayor-installer-mod/install.d/15createconfig.sh create mode 100755 mayor-installer-mod/install.d/20mysql.sh create mode 100755 mayor-installer-mod/install.d/25apache.sh create mode 100755 mayor-installer-mod/install.d/30php.sh create mode 100755 mayor-installer-mod/install.d/35createdatabases.sh create mode 100755 mayor-installer-mod/install.d/40binary.sh create mode 100755 mayor-installer-mod/install.d/45intezmeny.sh create mode 100755 mayor-installer-mod/install.d/50linker.sh create mode 100755 mayor-installer-mod/install.d/55tex.sh create mode 100755 mayor-installer-mod/install.d/60portal.sh create mode 100644 mayor-installer-mod/log/mayor-installer.rev create mode 100755 mayor-installer-mod/setup delete mode 100755 mayor-installer/install.d/05checkdeb.sh delete mode 100755 mayor-installer/install.d/10getsource.sh delete mode 100755 mayor-installer/install.d/15createconfig.sh delete mode 100755 mayor-installer/install.d/20mysql.sh delete mode 100755 mayor-installer/install.d/25apache.sh delete mode 100755 mayor-installer/install.d/30php.sh delete mode 100755 mayor-installer/install.d/35createdatabases.sh delete mode 100755 mayor-installer/install.d/40binary.sh delete mode 100755 mayor-installer/install.d/45intezmeny.sh delete mode 100755 mayor-installer/install.d/50linker.sh delete mode 100755 mayor-installer/install.d/55tex.sh delete mode 100755 mayor-installer/install.d/60portal.sh delete mode 100644 mayor-installer/log/mayor-installer.rev delete mode 100755 mayor-installer/setup create mode 100644 mayor-mod/bin/backup.sh create mode 100644 mayor-mod/bin/crypt-backup.sh create mode 100644 mayor-mod/bin/decrypt-backup.sh create mode 100755 mayor-mod/bin/etc/cron.daily/mayor create mode 100644 mayor-mod/bin/help.sh create mode 100644 mayor-mod/bin/lock.sh create mode 100755 mayor-mod/bin/mayor create mode 100644 mayor-mod/bin/remote-backup.sh create mode 100644 mayor-mod/bin/restore.sh create mode 100755 mayor-mod/bin/sbin/eNaploBackup.sh create mode 100755 mayor-mod/bin/sbin/eNaploRestore.sh create mode 100644 mayor-mod/bin/sbin/update.sh create mode 100644 mayor-mod/bin/tex2pdf.sh create mode 100644 mayor-mod/bin/unlock.sh create mode 100644 mayor-mod/bin/update.sh create mode 100644 mayor-mod/bin/xetex2pdf.sh create mode 100644 mayor-mod/update/processUpdateScripts.sh create mode 100644 mayor-mod/update/processUpdateScripts.sh.mod.txt create mode 100644 mayor-mod/update/processUpdateScripts.sh.orig create mode 100644 mayor-mod/www/include/modules/naplo/share/file.php delete mode 100644 mayor/bin/backup.sh delete mode 100644 mayor/bin/crypt-backup.sh delete mode 100644 mayor/bin/decrypt-backup.sh delete mode 100755 mayor/bin/etc/cron.daily/mayor delete mode 100644 mayor/bin/help.sh delete mode 100644 mayor/bin/lock.sh delete mode 100755 mayor/bin/mayor delete mode 100644 mayor/bin/remote-backup.sh delete mode 100644 mayor/bin/restore.sh delete mode 100755 mayor/bin/sbin/eNaploBackup.sh delete mode 100755 mayor/bin/sbin/eNaploRestore.sh delete mode 100644 mayor/bin/sbin/update.sh delete mode 100644 mayor/bin/tex2pdf.sh delete mode 100644 mayor/bin/unlock.sh delete mode 100644 mayor/bin/update.sh delete mode 100644 mayor/bin/xetex2pdf.sh delete mode 100644 mayor/update/processUpdateScripts.sh delete mode 100644 mayor/update/processUpdateScripts.sh.mod.txt delete mode 100644 mayor/update/processUpdateScripts.sh.orig delete mode 100644 mayor/www/include/modules/naplo/share/file.php diff --git a/mayor-installer-fcgi-mod/fcgi_install.d/01createhome.sh b/mayor-installer-fcgi-mod/fcgi_install.d/01createhome.sh new file mode 100755 index 00000000..bdb7398a --- /dev/null +++ b/mayor-installer-fcgi-mod/fcgi_install.d/01createhome.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# + +cat < (apache2=fcgid): <==IPC==> :php-értelmező_apache_gyermekprocesszként_külön_userként + + +FONTOS!! +A napló is ebből a könyvtárból fog futni, a /var/mayor/ egy symlink lesz +erre a könyvtárra. de ugyanúgy használható továbbra is, mint eddig. + +Például: + A felhasználó neve: mayor-web + A home könyvtára : /home/mayor-web/ + A mayor könyvtára : /home/mayor-web/mayor/ + A mayor mantés(pl): /home/mayor-web/mayor_backup/ + (Megj: a /var/mayor/ továbbra is használható.) + (/var/mayor/ --> /home/mayor-web/mayor/) + +A telepítés végén pedig mindez a >> ps auxf parancs kiadásával személetesebben is látszódik. +EOF + + +echo -e "A php értelmező felhasználója: $MAYORUSER" +read -n 1 -p "Létrehozhatom? (i/N) " -s DO +if [ "$DO" != "i" ]; then echo -e "\nA $MAYORUSER létrehozását kihagytam.\n"; exit 1; fi + +useradd -p "*" -m --home "/home/$MAYORUSER" --shell "/bin/false" --system "$MAYORUSER" +chage --mindays 0 --maxdays 99999 --warndays 7 "$MAYORUSER" +chfn --full-name "$MAYORUSER" "$MAYORUSER" +echo -e "A $MAYORUSER (rendszer)felhasználó hozzáadva.\n" + +echo -e "/home/$MAYORUSER/mayor és mayor_backup mappák létrehozása.\n" +mkdir -p "/home/$MAYORUSER/mayor_backup" +mkdir -p "/home/$MAYORUSER/mayor" + +echo -e "linkelés a /var/mayor könyvtárra.\n" +ln -s "/home/$MAYORUSER/mayor" "/var/mayor" + +echo -e "kész.\n\n" + + diff --git a/mayor-installer-fcgi-mod/fcgi_install.d/05checkdeb.sh b/mayor-installer-fcgi-mod/fcgi_install.d/05checkdeb.sh new file mode 100755 index 00000000..5b5e1828 --- /dev/null +++ b/mayor-installer-fcgi-mod/fcgi_install.d/05checkdeb.sh @@ -0,0 +1,106 @@ +#!/bin/bash +# +DEBIAN=false; +UBUNTU=false; +if [ $(which lsb_release || echo "notinstalled") == "notinstalled" ] +then + ISSUE=$(cat /etc/issue | cut -d " " -f 1) + if [ "x${ISSUE}" == "xDebian" ]; then + DEBIAN=true; + RELEASE=$(cat /etc/issue | cut -d " " -f 3) + elif [ "x${ISSUE}" == "xUbuntu" ]; then + UBUNTU=true; + RELEASE=$(cat /etc/issue | cut -d " " -f 2) + fi +else + DISTRIBUTOR=$(lsb_release -i -s) + RELEASE=$(lsb_release -r -s) + if [ "x${DISTRIBUTOR}" == "xDebian" ]; then + DEBIAN=true; + elif [ "x${DISTRIBUTOR}" == "xUbuntu" ]; then + UBUNTU=true; + fi +fi +echo "Debian:" ${DEBIAN} +echo "Ubuntu:" ${UBUNTU} +echo "Version:" ${RELEASE} + +TEST=$(grep contrib /etc/apt/sources.list) +if [ "$TEST" == "" ] +then + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "Az apt sources.list módosítása szükséges!" + if [ DEBIAN ]; then + echo "Debian Jessie (8) esetén például: + deb http://ftp.hu.debian.org/debian/ jessie main contrib non-free + deb http://security.debian.org/ jessie/updates main contrib non-free + deb http://ftp.hu.debian.org/debian/ jessie-updates main contrib non-free + +Debian 9 esetén például: + deb http://ftp.hu.debian.org/debian/ stretch main contrib non-free + deb http://security.debian.org/debian-security stretch/updates main contrib non-free + deb http://ftp.hu.debian.org/debian/ stretch-updates main contrib non-free + \n" + + read -n 1 -p "Hozzáadhatom? (egyelőre csak Debian9 esetén működik) (i/N)" -s DO + if [ "$DO" != "i" ]; then echo -e "\nA hozzáadást kihagytam.\n"; exit 255; fi + + if [[ "x${RELEASE}" =~ ^x9.* ]]; then + echo -e "#mayor miatt is: +deb http://ftp.hu.debian.org/debian/ stretch contrib non-free +deb http://security.debian.org/debian-security stretch/updates contrib non-free +deb http://ftp.hu.debian.org/debian/ stretch-updates contrib non-free" >> /etc/apt/sources.list + + fi + echo -e "\n ---- csomaglista frissítése ---- \n" + apt update ## frisítés + echo -e "\n ------------- kész ------------- \n" + + fi +# exit 255; +fi + +if [[ "x${RELEASE}" =~ ^x9.* ]] +then + PKGS="apache2 apache2-suexec-custom libapache2-mod-fcgid php-cgi php php-json php-mysql php-ldap php-mbstring php-mcrypt php-curl mariadb-server recode texlive texlive-fonts-extra texlive-latex-extra texlive-binaries texlive-xetex ntp wget ssl-cert ssh pwgen texlive-lang-european" +else + PKGS="apache2 apache2-suexec-custom libapache2-mod-fcgid php5-cgi php5 php5-json php5-mysqlnd php5-ldap php5-mcrypt php5-curl mysql-server recode texlive texlive-fonts-extra texlive-latex-extra texlive-binaries texlive-xetex ttf-mscorefonts-installer ntp wget ssl-cert ssh pwgen texlive-lang-european texlive-lang-hungarian" +fi + +if [ "$1" == "--no-deb" ]; then + exit 1 +fi + +cat </dev/null | sed 's/.*-\([^-]*\)\.tgz$/\1/' ) + +DO=n +if [ "$MENU" == '' ]; then + DO=i +else + echo " 0 Letöltés mindenképpen" + echo "${MENU}" | sed 's/.*-\([^-]*\)\.tgz$/\1/' | nl + read -n1 -p 'Melyiket telepítsem? ' SEL; echo + + if [ "$SEL" == 0 ]; then + DO=i + else + SELECT=$( echo "${MENU}" | sed -n ${SEL}p ) + + MAYORBASE="$TMPDIR/mayor-base-$SELECT.tgz" + MAYORNAPLO="$TMPDIR/mayor-naplo-$SELECT.tgz" + fi +fi + +if [ "$DO" == "i" ]; then + MAYORBASE="$TMPDIR/mayor-base-current.tgz" + MAYORNAPLO="$TMPDIR/mayor-naplo-current.tgz" + + echo -e "\nForrások letöltése:" + cd $TMPDIR + rm -f mayor-base-current.tgz + rm -f mayor-naplo-current.tgz + wget "http://www.mayor.hu/download/$VERSION/mayor-base-current.tgz" + wget "http://www.mayor.hu/download/$VERSION/mayor-naplo-current.tgz" +else + echo -e "\nA forráscsomagok letöltését kihagytam.\n" +fi + +read -n 1 -p "Telepítsem a forrás csomagokat? (i/N)" -s DO +if [ "$DO" != "i" ]; then echo -e "\nA forráscsomagok telepítését kihagytam.\n"; exit 1; fi + +echo -n -e "\nRendszer könyvtár: " +if [ ! -e $MAYORDIR ]; then + mkdir -p $MAYORDIR +fi +if [ ! -e "/var/mayor" ]; then + ln -s $MAYORDIR /var/mayor +fi +echo $MAYORDIR + +echo -e -n "Források kicsomagolása... " +cd $MAYORDIR +tar xfz "$MAYORBASE" +tar xfz "$MAYORNAPLO" +echo "ok." + diff --git a/mayor-installer-fcgi-mod/fcgi_install.d/15createconfig.sh b/mayor-installer-fcgi-mod/fcgi_install.d/15createconfig.sh new file mode 100755 index 00000000..74156932 --- /dev/null +++ b/mayor-installer-fcgi-mod/fcgi_install.d/15createconfig.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# + +cat < " + PW=$(pwgen -s1 32) + cat "$MAYORDIR/config/$file.example" | sed s/%SQLPW%/$PW/ > "$MAYORDIR/config/$file" + echo $file + fi +done + +echo -n " module-naplo/config.php.example --> " +PW=$(pwgen -s1 32) +PWREAD=$(pwgen -s1 32) +if [ -e "$MAYORDIR/config/module-naplo/config.php" ]; then echo " module-naplo/config.php létezik."; else + cat "$MAYORDIR/config/module-naplo/config.php.example" | sed -e s/%SQLPW%/$PW/ -e s/%SQLPWREAD%/$PWREAD/ > "$MAYORDIR/config/module-naplo/config.php" + echo "module-naplo/config.php" +fi + +if [ -e "$MAYORDIR/config/skin-classic/naplo-config.php" ]; then echo " skin-classic/naplo-config.php létezik."; else + echo -n " skin-classic/naplo-config.php.example --> " + cp $MAYORDIR/config/skin-classic/naplo-config.php.example $MAYORDIR/config/skin-classic/naplo-config.php + echo "config/skin-classic/naplo-config.php" +fi + + +sed -e "s/\/var\/mayor/\/home\/$MAYORUSER\/mayor/g" -i "$MAYORDIR/config/main-config.php" diff --git a/mayor-installer-fcgi-mod/fcgi_install.d/20mysql.sh b/mayor-installer-fcgi-mod/fcgi_install.d/20mysql.sh new file mode 100755 index 00000000..7ae70bfb --- /dev/null +++ b/mayor-installer-fcgi-mod/fcgi_install.d/20mysql.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# + +cat < /etc/mysql/conf.d/utf8.cnf + +#cp -f $MAYORDIR/install/base/mysql/utf8.cnf /etc/mysql/conf.d +echo ok +/etc/init.d/mysql restart + +if [ "x${RELEASE}" == "x9" ] +then + echo -e "\nMariaDB/MySQL beállítások" + echo -n " futtatom a mysql_Secure_installation scriptet: " + mysql_secure_installation +fi diff --git a/mayor-installer-fcgi-mod/fcgi_install.d/25apache.sh b/mayor-installer-fcgi-mod/fcgi_install.d/25apache.sh new file mode 100755 index 00000000..d2aa12c7 --- /dev/null +++ b/mayor-installer-fcgi-mod/fcgi_install.d/25apache.sh @@ -0,0 +1,254 @@ +#!/bin/bash +# + +cat < /dev/null + echo ok +else + echo "már engedélyezett" +fi + echo -n " - ModReWrite engedélyezése ... " +if [ ! -e /etc/apache2/mods-enabled/rewrite.load ]; then + a2enmod rewrite > /dev/null + echo ok +else + echo "már engedélyezett" +fi + +echo -n " - mod_suexec engedélyezése ... " +if [ ! -e /etc/apache2/mods-enabled/suexec.load ]; then + a2enmod suexec > /dev/null + echo ok +else + echo "már engedélyezett" +fi + +echo -n " - mod_fcgid engedélyezése ... " +if [ ! -e /etc/apache2/mods-enabled/fcgid.load ]; then + a2enmod fcgid > /dev/null + echo ok +else + echo "már engedélyezett" +fi + +echo -n " - mod_actions engedélyezése ... " +if [ ! -e /etc/apache2/mods-enabled/actions.load ]; then + a2enmod actions > /dev/null + echo ok +else + echo "már engedélyezett" +fi + + +echo -n " - mod_php kikapcsolása (a www-data php értelmezője)" +if [ -e /etc/apache2/mods-enabled/php7.0.load ]; then + a2dismod php7.0 > /dev/null + echo ok +else + echo "nincs bekapcsolava" +fi + +echo -n " - mod_headers engedélyezése" +if [ ! -e /etc/apache2/mods-enabled/headers.load ]; then + a2enmod headers > /dev/null + echo ok +else + echo "nincs bekapcsolava" +fi + + +echo -n " - Apache2 mod_worker és mod_event, amíg a php nem lesz thread-safe. " +if [ -e /etc/apache2/mods-enabled/mpm_event.load ] || [ -e /etc/apache2/mods-enabled/mpm_worker.load ]; then + a2dismod mpm_event > /dev/null + a2dismod mpm_worker > /dev/null + a2enmod mpm_prefork > /dev/null + echo ok +else + echo "nincs bekapcsolava" +fi + +echo "ok." + + +echo -e " Apache2 konfiguráció létrehozása\n" +cat > /etc/apache2/sites-available/mayor_naplo.conf < + ServerName your.mayor.server.hu +# ServerAlias your.mayor.server.hu your.mayor.server.iskola.sulinet.hu + + + ServerAdmin webmaster@localhost + + SuexecUserGroup mayor-user mayor-user + DocumentRoot mayor-docroot + ScriptAlias /wbin/ mayor-web-bin + + AddHandler php-fcgi .php + Action php-fcgi /wbin/php7.fcgi + AddType application/x-httpd-php .php + + + FcgidProcessLifeTime 3600 + FcgidIOTimeout 320 + FcgidMaxRequestInMem 16777216 + FcgidMaxRequestLen 33554432 + FcgidBusyTimeout 600 +## FcgidOutputBufferSize 0 + FcgidIdleTimeout 400 + + +# Részletesebben: +# FcgidProcessLifeTime 3600 ##(seconds) A php max futási ideje (a (hagyományos) mod_php-nál is ennyi) +# FcgidIOTimeout 320 ##(seconds) A php generál valamit, elkldi a böngészőnek, vagy a böngésző küld adatot a php-nak, ennyi ideig tarthat. (pl: 120sec) +# FcgidMaxRequestInMem 16777216 ##(bytes) Amikor a böngésző küld adatokat a php-nak, ennyi megy a pufferbe. (16MB elég) +# FcgidMaxRequestLen 33554432 ##(bytes) Amikor a böngésző küld adatot a php-nak, az adat max hossza bájtokabn. (32MB elég) +# FcgidBusyTimeout 600 ##(seconds) A php max ennyi ideig gondolkozhat egy futáson/kérésen, ha túllépi, ki lesz lőve. +# FcgidOutputBufferSize 0 ##(bytes) Pufer, amikor a php generál valami adatot, és azt elküldené a böngészőnek. {ezt még át kéne nézni} +# FcgidIdleTimeout 400 ##(seconds) A php-értelmező ennyi pihenés után le lesz állítva.(**) +# ##(**) Figyelem! Itt a "php-értelmező" külön gyermekprocesszként fut, ami az oldal meglátogatásakor indul automatikusan, +# ## és FcgidIdleTimeout-nyi pihenés után magától leáll. + + IndexIgnore * + + + ## A php-csomagoló, és php.ini fájlok közvetlen elérésének tiltása + + Require all granted + + Require env REDIRECT_STATUS + + + Require all denied + + + Require all denied + + + + DirectoryIndex index.php index.html index.htm + + + Options FollowSymLinks + AllowOverride None + + + + Options -Indexes +FollowSymLinks +MultiViews + AllowOverride None + # Apache 2.2 # Order allow,deny + # Apache 2.2 # allow from all + # Apache 2.4 # Require all granted + = 2.3> + Require all granted + + + order allow,deny + allow from all + + RewriteEngine on + RewriteBase / + RewriteCond %{SERVER_PORT} ^80$ + RewriteCond %{THE_REQUEST} .*(policy=private|page=auth|page=password).* + RewriteRule (.*)$ https://%{HTTP_HOST}/$1 [L] + + + + SSLEngine On +# ## A gyenge titkosítások tiltása + SSLProtocol all -SSLv2 -SSLv3 -TLSv1 + SSLCertificateFile /etc/apache2/ssl/apache_mayor.pem +# # SSLCertificateFile /etc/apache2/ssl/crt/name-cert.pem +# # SSLCertificateKeyFile /etc/apache2/ssl/key/name-key.pem + + + + Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains" + + + + ErrorLog \${APACHE_LOG_DIR}/mayor_error.log + + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel info ssl:warn fcgid:debug + + CustomLog \${APACHE_LOG_DIR}/mayor_access.log combined + ServerSignature On + + +EOT + + + +SERVERNAME="" +while [ "$SERVERNAME" = "" ] +do + read -p " A web szerver teljes domain neve (pl: mayor.tesztsuli.hu): " SERVERNAME +done + +#cat $MAYORDIR/install/base/apache2/mayor.conf | sed "s/ServerName your.mayor.server.hu/ServerName $SERVERNAME/" > /etc/apache2/sites-available/mayor.conf + +# A 2.4-es apache esetén módosítani kell a konfig állományt! +APACHE_VERSION=$(dpkg -l apache2 | grep apache2 | tr -s ' ' | cut -d ' ' -f 3 | cut -d '-' -f 1 | sed 's/\..$//') + +echo -e " Apache2 finomhangolása\n" + +sed -e "s/ServerName your.mayor.server.hu/ServerName $SERVERNAME/g" -i /etc/apache2/sites-available/mayor_naplo.conf +sed -e "s/SuexecUserGroup mayor-user mayor-user/SuexecUserGroup $MAYORUSER $MAYORUSER/g" -i /etc/apache2/sites-available/mayor_naplo.conf +sed -e "s/DocumentRoot mayor-docroot/DocumentRoot \/home\/$MAYORUSER\/mayor\/www\/ /g" -i /etc/apache2/sites-available/mayor_naplo.conf +sed -e "s/ScriptAlias \/wbin\/ mayor-web-bin/ScriptAlias \/wbin\/ \/home\/$MAYORUSER\/mayor\/www-bin\/ /g" -i /etc/apache2/sites-available/mayor_naplo.conf +sed -e "s// /g" -i /etc/apache2/sites-available/mayor_naplo.conf +sed -e "s// /g" -i /etc/apache2/sites-available/mayor_naplo.conf + +echo -e " a suexec beállítása\n" +sed -e 's/\/var\/www/\/home\n\/var\/www/g' -i /etc/apache2/suexec/www-data + +echo " A php-csomagoló elkészítése" +mkdir -p "/home/$MAYORUSER/mayor/www-bin/" + +csomagolo="#!/bin/sh \n exec /usr/bin/php-cgi7.0 " +echo -e $csomagolo > "/home/$MAYORUSER/mayor/www-bin/php7.fcgi" +chmod +x "/home/$MAYORUSER/mayor/www-bin/php7.fcgi" + +echo " A php.ini beszerzése" +cp "/etc/php/7.0/cgi/php.ini" "/home/$MAYORUSER/mayor/www-bin/php.ini" +chown -R "$MAYORUSER:$MAYORUSER" "/home/$MAYORUSER/mayor/www-bin" + + +if [ ! -e /etc/apache2/sites-enabled/mayor_naplo.conf ]; then + echo " A mayor site engedélyezése" + a2ensite mayor_naplo.conf > /dev/null +fi + +echo " A web-szerver újraindítása" +/etc/init.d/apache2 restart diff --git a/mayor-installer-fcgi-mod/fcgi_install.d/30php.sh b/mayor-installer-fcgi-mod/fcgi_install.d/30php.sh new file mode 100755 index 00000000..3e4545a2 --- /dev/null +++ b/mayor-installer-fcgi-mod/fcgi_install.d/30php.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# + +cat < mayor-login.sql +DB=$(grep db $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +USER=$(grep user $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +PW=$(grep pw $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +cat $MAYORDIR/install/base/mysql/mayor-auth.sql | sed -e "s/%MYSQL_AUTH_DB%/$DB/g" -e "s/%MYSQL_AUTH_USER%/$USER/g" \ + -e "s/%MYSQL_AUTH_PW%/$PW/g" > mayor-parent.sql +DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +USER=$(grep 'mysql user' $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +PW=$(grep pw $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +cat $MAYORDIR/install/base/mysql/mayor-auth.sql | sed -e "s/%MYSQL_AUTH_DB%/$DB/g" -e "s/%MYSQL_AUTH_USER%/$USER/g" \ + -e "s/%MYSQL_AUTH_PW%/$PW/g" > mayor-private.sql +DB=$(grep db $MAYORDIR/config/module-naplo/config.php | grep naplo_base | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +USER=$(egrep 'userWrite.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +USERREAD=$(egrep 'userRead.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +PW=$(egrep 'pwWrite.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +PWREAD=$(egrep 'pwRead.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +cat $MAYORDIR/install/module-naplo/mysql/base.sql | sed -e "s/%MYSQL_NAPLO_DB%/$DB/g" -e "s/%MYSQL_NAPLO_USER%/$USER/g" \ + -e "s/%MYSQL_NAPLO_PW%/$PW/g" -e "s/%MYSQL_NAPLO_USER_READ%/$USERREAD/g" \ + -e "s/%MYSQL_NAPLO_PW_READ%/$PWREAD/g" > base.sql +DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") + +cat $MAYORDIR/install/base/mysql/private-users.sql | sed -e "s/%MYSQL_PRIVATE_DB%/$DB/g" > private-users.sql +cat $MAYORDIR/install/module-naplo/mysql/naplo-users.sql | sed -e "s/%MYSQL_PRIVATE_DB%/$DB/g" > naplo-users.sql + +echo " A létrejött sql fileok:" +FILES=$(ls *.sql) +for f in $FILES +do + echo " * ${f}"; +done; +read -n 1 -p "Telepíthetem? (i/N)" -s DO +if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi +echo -e "\n" + +read -p " A mysql root jelszó (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW + +if [ ! -e $MAYORDIR/config/main.conf ]; then + cat $MAYORDIR/config/main.conf.example | sed s/%SQLPW%/$MYSQLROOTPW/ > $MAYORDIR/config/main.conf + chmod 600 $MAYORDIR/config/main.conf +fi + +if [ "$MYSQLROOTPW" = "" ]; +then + MYSQLROOTPWSTR=""; +else + MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" +fi + +cat /tmp/mysql/mayor-login.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/mayor-parent.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/mayor-private.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/base.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/private-users.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/naplo-users.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 + +echo -e "\n" +echo "A telepítés végeztével beléphetsz a webes felületen! +========================================================= + user: mayoradmin +========================================================= + jelszó: jelszo +========================================================= +" diff --git a/mayor-installer-fcgi-mod/fcgi_install.d/40binary.sh b/mayor-installer-fcgi-mod/fcgi_install.d/40binary.sh new file mode 100755 index 00000000..33acc60d --- /dev/null +++ b/mayor-installer-fcgi-mod/fcgi_install.d/40binary.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# + +cat < $TMPDIR/mysql/intezmeny.sql + +insert into $DB.intezmeny (OMKod, rovidNev, nev, alapertelmezett) VALUES ('$OMKOD','$ROVID','$INTEZMENYNEV',1); +create database intezmeny_$ROVID character set utf8 collate utf8_hungarian_ci; +grant select,execute on intezmeny_$ROVID.* to '$USERREAD'@'localhost'; +grant all on intezmeny_$ROVID.* to '$USER'@'localhost'; +use intezmeny_$ROVID; + +EOF + +if [ "$MYSQLROOTPW" == "" ]; then + read -p " A mysql root jelszó -ha van!- (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW +fi +#Ezt miért is akarom kiírni? +#echo $MYSQLROOTPW - a jelszó +if [ "$MYSQLROOTPW" = "" ]; +then + MYSQLROOTPWSTR=""; +else + MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" +fi + +cat $TMPDIR/mysql/intezmeny.sql $MAYORDIR/install/module-naplo/mysql/intezmeny.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 $INTEZMENYDB diff --git a/mayor-installer-fcgi-mod/fcgi_install.d/50linker.sh b/mayor-installer-fcgi-mod/fcgi_install.d/50linker.sh new file mode 100755 index 00000000..bd4910a9 --- /dev/null +++ b/mayor-installer-fcgi-mod/fcgi_install.d/50linker.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# +cat < $MAYORDIR/www/policy/$POLICY/$file" + ln -s $MAYORDIR/www/policy/private/$file $MAYORDIR/www/policy/$POLICY/$file + else + echo " Hiányzó file: $MAYORDIR/www/policy/private/$file" + fi + else + echo " [OK] A file már létezik: " $file + fi + done + done +done diff --git a/mayor-installer-fcgi-mod/fcgi_install.d/55tex.sh b/mayor-installer-fcgi-mod/fcgi_install.d/55tex.sh new file mode 100755 index 00000000..87bcbc5f --- /dev/null +++ b/mayor-installer-fcgi-mod/fcgi_install.d/55tex.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +cat < " + PW=$(pwgen -s1 32) + if [ "$ROVID" = "" ]; then + ROVID="demo" + fi + cat "$MAYORDIR/config/$file.example" | sed -e "s/%SQLPW%/$PW/" -e "s/demo/${ROVID}/" > "$MAYORDIR/config/$file" + echo $file +fi + +echo -e "\n SQL file létrehozása... " +if [ ! -d $TMPDIR/mysql ]; then + mkdir -p $TMPDIR/mysql +fi +cd $TMPDIR/mysql +PDB=$(grep db $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") +USER=$(grep user $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") +PW=$(grep pw $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") + +cat $MAYORDIR/install/mayor-portal/mysql/mayor-portal.sql | sed \ + -e "s/%MYSQL_PORTAL_DB%/$PDB/g" \ + -e "s/%MYSQL_PORTAL_USER%/$USER/g" \ + -e "s/%MYSQL_PORTAL_PW%/$PW/g" > mayor-portal.sql + +DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +cat $MAYORDIR/install/mayor-portal/mysql/portal-init.sql | sed \ + -e "s/%MYSQL_PRIVATE_DB%/$DB/g" \ + -e "s/%MYSQL_PORTAL_DB%/$PDB/g" > portal-init.sql + +read -n 1 -p "Telepíthetem? (i/N)" -s DO +if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi +echo -e "\n" + +if [ "$MYSQLROOTPW" == "" ]; then + read -p " A mysql root jelszó -ha van- (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW +fi + +if [ "$MYSQLROOTPW" = "" ]; +then + MYSQLROOTPWSTR=""; +else + MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" +fi + + +cat /tmp/mysql/mayor-portal.sql /tmp/mysql/portal-init.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 + +read -n 1 -p "Tegyük a portál oldalt a rendszer kezdőlapjává minden hozzáférési szinten? (i/N)" -s DO +if [ "$DO" != "i" ]; then + echo -e "\nA portál oldalt nem teszem kezdőlappá.\n"; + cat <'portal', 'sub' => 'portal', 'f' => 'portal');/" $MAYORDIR/config/$file + echo ok + done +fi + +if [ "$ROVID" != "demo" ]; then + echo -e "\nEgyedi kezdőoldalak létrehozása:" + for policy in private public parent; do + echo -n " $policy " + for skin in classic pda; do + cp $MAYORDIR/www/policy/$policy/portal/portal/portal_demo.$skin.php $MAYORDIR/www/policy/$policy/portal/portal/portal_$ROVID.$skin.php + echo -n "... " + done + echo "ok" + done +fi + diff --git a/mayor-installer-fcgi-mod/fcgi_install.d/90chown.sh b/mayor-installer-fcgi-mod/fcgi_install.d/90chown.sh new file mode 100755 index 00000000..1e090128 --- /dev/null +++ b/mayor-installer-fcgi-mod/fcgi_install.d/90chown.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +echo -e "A könyvtárak jogosultságainak beállítása\n\n" +read -n 1 -p "beállíthatom? (i/N)" -s DO +if [ "$DO" != "i" ]; then echo -e "\nNem.\n"; exit 1; fi + + +if [ $MAYORUSER == "" ] || [ $MAYORDIR == "" ]; then echo -e "A MAYOR(DIR/USER) változó üres! .....kilépek\n" ; exit 1 ; fi + +chown -R "$MAYORUSER:$MAYORUSER" /home/$MAYORUSER/ ## Ez esetben a MAYORDIR a /home/xxx/mayor-ra mutat + +find /home/$MAYORUSER/ -type f -print0 | xargs -0 chmod 0644 +find /home/$MAYORUSER/ -type d -print0 | xargs -0 chmod 0751 +find /home/$MAYORUSER/ -name '*.php' -print0 | xargs -0 chmod 0640 +find /home/$MAYORUSER/mayor/ -name '*.sh' -print0 | xargs -0 chmod 0600 +find /home/$MAYORUSER/mayor/bin/ -name '*.sh' -print0 | xargs -0 chown root:root +find /home/$MAYORUSER/mayor/ -name '*.conf' -print0 | xargs -0 chmod 0600 + +# a csomagoló jogainak visszaállítása +chmod -R 600 "/home/$MAYORUSER/mayor/www-bin/" +chmod +x "/home/$MAYORUSER/mayor/www-bin/php7.fcgi" + +## de azért idemásolom az eredetit is, biztos-ami-biztos +chmod 700 $MAYORDIR/config/ +# A main.conf védelme +chown root:root $MAYORDIR/config/main.conf +chmod 600 $MAYORDIR/config/main.conf + + +echo -e "...kész.\n" \ No newline at end of file diff --git a/mayor-installer-fcgi-mod/fcgi_install.d/99end.sh b/mayor-installer-fcgi-mod/fcgi_install.d/99end.sh new file mode 100755 index 00000000..fab52dc8 --- /dev/null +++ b/mayor-installer-fcgi-mod/fcgi_install.d/99end.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo -e "-------------------------------------------------\n" +echo -e "Telepítés vége. \n\n" + + + diff --git a/mayor-installer-fcgi-mod/install.d/05checkdeb.sh b/mayor-installer-fcgi-mod/install.d/05checkdeb.sh new file mode 100755 index 00000000..2488d60a --- /dev/null +++ b/mayor-installer-fcgi-mod/install.d/05checkdeb.sh @@ -0,0 +1,106 @@ +#!/bin/bash +# +DEBIAN=false; +UBUNTU=false; +if [ $(which lsb_release || echo "notinstalled") == "notinstalled" ] +then + ISSUE=$(cat /etc/issue | cut -d " " -f 1) + if [ "x${ISSUE}" == "xDebian" ]; then + DEBIAN=true; + RELEASE=$(cat /etc/issue | cut -d " " -f 3) + elif [ "x${ISSUE}" == "xUbuntu" ]; then + UBUNTU=true; + RELEASE=$(cat /etc/issue | cut -d " " -f 2) + fi +else + DISTRIBUTOR=$(lsb_release -i -s) + RELEASE=$(lsb_release -r -s) + if [ "x${DISTRIBUTOR}" == "xDebian" ]; then + DEBIAN=true; + elif [ "x${DISTRIBUTOR}" == "xUbuntu" ]; then + UBUNTU=true; + fi +fi +echo "Debian:" ${DEBIAN} +echo "Ubuntu:" ${UBUNTU} +echo "Version:" ${RELEASE} + +TEST=$(grep contrib /etc/apt/sources.list) +if [ "$TEST" == "" ] +then + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "Az apt sources.list módosítása szükséges!" + if [ DEBIAN ]; then + echo "Debian Jessie (8) esetén például: + deb http://ftp.hu.debian.org/debian/ jessie main contrib non-free + deb http://security.debian.org/ jessie/updates main contrib non-free + deb http://ftp.hu.debian.org/debian/ jessie-updates main contrib non-free + +Debian 9 esetén például: + deb http://ftp.hu.debian.org/debian/ stretch main contrib non-free + deb http://security.debian.org/debian-security stretch/updates main contrib non-free + deb http://ftp.hu.debian.org/debian/ stretch-updates main contrib non-free + \n" + + read -n 1 -p "Hozzáadhatom? (egyelőre csak Debian9 esetén működik) (i/N)" -s DO + if [ "$DO" != "i" ]; then echo -e "\nA hozzáadást kihagytam.\n"; exit 255; fi + + if [[ "x${RELEASE}" =~ ^x9.* ]]; then + echo -e "#mayor miatt is: +deb http://ftp.hu.debian.org/debian/ stretch contrib non-free +deb http://security.debian.org/debian-security stretch/updates contrib non-free +deb http://ftp.hu.debian.org/debian/ stretch-updates contrib non-free" >> /etc/apt/sources.list + + fi + echo -e "\n ---- csomaglista frissítése ---- \n" + apt update ## frisítés + echo -e "\n ------------- kész ------------- \n" + + fi +# exit 255; +fi + +if [[ "x${RELEASE}" =~ ^x9.* ]] +then + PKGS="apache2 php libapache2-mod-php php-json php-mysql php-ldap php-mbstring php-mcrypt php-curl mariadb-server recode texlive texlive-fonts-extra texlive-latex-extra texlive-binaries texlive-xetex ntp wget ssl-cert ssh pwgen texlive-lang-european" +else + PKGS="apache2 php5 libapache2-mod-php5 php5-json php5-mysqlnd php5-ldap php5-mcrypt php5-curl mysql-server recode texlive texlive-fonts-extra texlive-latex-extra texlive-binaries texlive-xetex ttf-mscorefonts-installer ntp wget ssl-cert ssh pwgen texlive-lang-european texlive-lang-hungarian" +fi + +if [ "$1" == "--no-deb" ]; then + exit 1 +fi + +cat </dev/null | sed 's/.*-\([^-]*\)\.tgz$/\1/' ) + +DO=n +if [ "$MENU" == '' ]; then + DO=i +else + echo " 0 Letöltés mindenképpen" + echo "${MENU}" | sed 's/.*-\([^-]*\)\.tgz$/\1/' | nl + read -n1 -p 'Melyiket telepítsem? ' SEL; echo + + if [ "$SEL" == 0 ]; then + DO=i + else + SELECT=$( echo "${MENU}" | sed -n ${SEL}p ) + + MAYORBASE="$TMPDIR/mayor-base-$SELECT.tgz" + MAYORNAPLO="$TMPDIR/mayor-naplo-$SELECT.tgz" + fi +fi + +if [ "$DO" == "i" ]; then + MAYORBASE="$TMPDIR/mayor-base-current.tgz" + MAYORNAPLO="$TMPDIR/mayor-naplo-current.tgz" + + echo -e "\nForrások letöltése:" + cd $TMPDIR + rm -f mayor-base-current.tgz + rm -f mayor-naplo-current.tgz + wget "http://www.mayor.hu/download/$VERSION/mayor-base-current.tgz" + wget "http://www.mayor.hu/download/$VERSION/mayor-naplo-current.tgz" +else + echo -e "\nA forráscsomagok letöltését kihagytam.\n" +fi + +read -n 1 -p "Telepítsem a forrás csomagokat? (i/N)" -s DO +if [ "$DO" != "i" ]; then echo -e "\nA forráscsomagok telepítését kihagytam.\n"; exit 1; fi + +echo -n -e "\nRendszer könyvtár: " +if [ ! -e $MAYORDIR ]; then + mkdir -p $MAYORDIR +fi +if [ ! -e "/var/mayor" ]; then + ln -s $MAYORDIR /var/mayor +fi +echo $MAYORDIR + +echo -e -n "Források kicsomagolása... " +cd $MAYORDIR +tar xfz "$MAYORBASE" +tar xfz "$MAYORNAPLO" +echo "ok." + diff --git a/mayor-installer-fcgi-mod/install.d/15createconfig.sh b/mayor-installer-fcgi-mod/install.d/15createconfig.sh new file mode 100755 index 00000000..8d035fe1 --- /dev/null +++ b/mayor-installer-fcgi-mod/install.d/15createconfig.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# + +cat < " + PW=(pwgen -s1 32) + cat "$MAYORDIR/config/$file.example" | sed s/%SQLPW%/$PW/ > "$MAYORDIR/config/$file" + echo $file + fi +done + +echo -n " module-naplo/config.php.example --> " +PW=$(pwgen -s1 32) +PWREAD=$(pwgen -s1 32) +if [ -e "$MAYORDIR/config/module-naplo/config.php" ]; then echo " module-naplo/config.php létezik."; else + cat "$MAYORDIR/config/module-naplo/config.php.example" | sed -e s/%SQLPW%/$PW/ -e s/%SQLPWREAD%/$PWREAD/ > "$MAYORDIR/config/module-naplo/config.php" + echo "module-naplo/config.php" +fi + +if [ -e "$MAYORDIR/config/skin-classic/naplo-config.php" ]; then echo " skin-classic/naplo-config.php létezik."; else + echo -n " skin-classic/naplo-config.php.example --> " + cp $MAYORDIR/config/skin-classic/naplo-config.php.example $MAYORDIR/config/skin-classic/naplo-config.php + echo "config/skin-classic/naplo-config.php" +fi diff --git a/mayor-installer-fcgi-mod/install.d/20mysql.sh b/mayor-installer-fcgi-mod/install.d/20mysql.sh new file mode 100755 index 00000000..2979f728 --- /dev/null +++ b/mayor-installer-fcgi-mod/install.d/20mysql.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# + +cat < /dev/null + echo ok +else + echo "már engedélyezett" +fi + echo -n " - ModReWrite engedélyezése ... " +if [ ! -e /etc/apache2/mods-enabled/rewrite.load ]; then + a2enmod rewrite > /dev/null + echo ok +else + echo "már engedélyezett" +fi +echo "ok." + +SERVERNAME="" +while [ "$SERVERNAME" = "" ] +do + read -p " A web szerver teljes domain neve (pl: mayor.tesztsuli.hu): " SERVERNAME +done + +#cat $MAYORDIR/install/base/apache2/mayor.conf | sed "s/ServerName your.mayor.server.hu/ServerName $SERVERNAME/" > /etc/apache2/sites-available/mayor.conf + +# A 2.4-es apache esetén módosítani kell a konfig állományt! +APACHE_VERSION=$(dpkg -l apache2 | grep apache2 | tr -s ' ' | cut -d ' ' -f 3 | cut -d '-' -f 1 | sed 's/\..$//') +cat $MAYORDIR/install/base/apache2/mayor.conf | sed \ + -e "s/ServerName your.mayor.server.hu/ServerName $SERVERNAME/" > /etc/apache2/sites-available/mayor.conf + + +if [ ! -e /etc/apache2/sites-enabled/mayor.conf ]; then + echo " A mayor site engedélyezése" + a2ensite mayor.conf > /dev/null +fi + +echo " A web-szerver újraindítása" +/etc/init.d/apache2 restart diff --git a/mayor-installer-fcgi-mod/install.d/30php.sh b/mayor-installer-fcgi-mod/install.d/30php.sh new file mode 100755 index 00000000..49000c68 --- /dev/null +++ b/mayor-installer-fcgi-mod/install.d/30php.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# + +cat < /etc/php5/apache2/php.ini +echo 256M + +echo " Az web szerver újraindítása" +/etc/init.d/apache2 restart + diff --git a/mayor-installer-fcgi-mod/install.d/35createdatabases.sh b/mayor-installer-fcgi-mod/install.d/35createdatabases.sh new file mode 100755 index 00000000..718ca3c2 --- /dev/null +++ b/mayor-installer-fcgi-mod/install.d/35createdatabases.sh @@ -0,0 +1,132 @@ +#!/bin/bash +# + +cat < mayor-login.sql +DB=$(grep db $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +USER=$(grep user $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +PW=$(grep pw $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +cat $MAYORDIR/install/base/mysql/mayor-auth.sql | sed -e "s/%MYSQL_AUTH_DB%/$DB/g" -e "s/%MYSQL_AUTH_USER%/$USER/g" \ + -e "s/%MYSQL_AUTH_PW%/$PW/g" > mayor-parent.sql +DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +USER=$(grep 'mysql user' $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +PW=$(grep pw $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +cat $MAYORDIR/install/base/mysql/mayor-auth.sql | sed -e "s/%MYSQL_AUTH_DB%/$DB/g" -e "s/%MYSQL_AUTH_USER%/$USER/g" \ + -e "s/%MYSQL_AUTH_PW%/$PW/g" > mayor-private.sql +DB=$(grep db $MAYORDIR/config/module-naplo/config.php | grep naplo_base | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +USER=$(egrep 'userWrite.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +USERREAD=$(egrep 'userRead.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +PW=$(egrep 'pwWrite.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +PWREAD=$(egrep 'pwRead.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +cat $MAYORDIR/install/module-naplo/mysql/base.sql | sed -e "s/%MYSQL_NAPLO_DB%/$DB/g" -e "s/%MYSQL_NAPLO_USER%/$USER/g" \ + -e "s/%MYSQL_NAPLO_PW%/$PW/g" -e "s/%MYSQL_NAPLO_USER_READ%/$USERREAD/g" \ + -e "s/%MYSQL_NAPLO_PW_READ%/$PWREAD/g" > base.sql +DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") + +cat $MAYORDIR/install/base/mysql/private-users.sql | sed -e "s/%MYSQL_PRIVATE_DB%/$DB/g" > private-users.sql +cat $MAYORDIR/install/module-naplo/mysql/naplo-users.sql | sed -e "s/%MYSQL_PRIVATE_DB%/$DB/g" > naplo-users.sql + +echo " A létrejött sql fileok:" +FILES=$(ls *.sql) +for f in $FILES +do + echo " * ${f}"; +done; +read -n 1 -p "Telepíthetem? (i/N)" -s DO +if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi +echo -e "\n" + +read -p " A mysql root jelszó (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW + + +if [ ! -e $MAYORDIR/config/main.conf ]; then + cat $MAYORDIR/config/main.conf.example | sed s/%SQLPW%/$MYSQLROOTPW/ > $MAYORDIR/config/main.conf +# BDIR=$(echo $MAYORDIR | sed -e 's:\/:\\\/:g') +# sed -e "s/BASEDIR=\"\/var\/mayor\"/BASEDIR=\"$BDIR\"/g" -i $MAYORDIR/config/main.conf + chmod 600 $MAYORDIR/config/main.conf +fi + +if [ "$MYSQLROOTPW" = "" ]; +then + MYSQLROOTPWSTR=""; +else + MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" +fi + +cat /tmp/mysql/mayor-login.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/mayor-parent.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/mayor-private.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/base.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/private-users.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/naplo-users.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 + +echo -e "\n" +echo "A telepítés végeztével beléphetsz a webes felületen! +========================================================= + user: mayoradmin +========================================================= + jelszó: jelszo +========================================================= +" diff --git a/mayor-installer-fcgi-mod/install.d/40binary.sh b/mayor-installer-fcgi-mod/install.d/40binary.sh new file mode 100755 index 00000000..e0f0598b --- /dev/null +++ b/mayor-installer-fcgi-mod/install.d/40binary.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# + +cat < $TMPDIR/mysql/intezmeny.sql + +insert into $DB.intezmeny (OMKod, rovidNev, nev, alapertelmezett) VALUES ('$OMKOD','$ROVID','$INTEZMENYNEV',1); +create database intezmeny_$ROVID character set utf8 collate utf8_hungarian_ci; +grant select,execute on intezmeny_$ROVID.* to '$USERREAD'@'localhost'; +grant all on intezmeny_$ROVID.* to '$USER'@'localhost'; +use intezmeny_$ROVID; + +EOF + +if [ "$MYSQLROOTPW" == "" ]; then + read -p " A mysql root jelszó -ha van!- (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW +fi +#Ezt miért is akarom kiírni? +#echo $MYSQLROOTPW - a jelszó +if [ "$MYSQLROOTPW" = "" ]; +then + MYSQLROOTPWSTR=""; +else + MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" +fi + +cat $TMPDIR/mysql/intezmeny.sql $MAYORDIR/install/module-naplo/mysql/intezmeny.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 $INTEZMENYDB diff --git a/mayor-installer-fcgi-mod/install.d/50linker.sh b/mayor-installer-fcgi-mod/install.d/50linker.sh new file mode 100755 index 00000000..73887902 --- /dev/null +++ b/mayor-installer-fcgi-mod/install.d/50linker.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +cat < $MAYORDIR/www/policy/$POLICY/$file" + ln -s $MAYORDIR/www/policy/private/$file $MAYORDIR/www/policy/$POLICY/$file + else + echo " Hiányzó file: $MAYORDIR/www/policy/private/$file" + fi + else + echo " [OK] A file már létezik: " $file + fi + done + done +done diff --git a/mayor-installer-fcgi-mod/install.d/55tex.sh b/mayor-installer-fcgi-mod/install.d/55tex.sh new file mode 100755 index 00000000..87bcbc5f --- /dev/null +++ b/mayor-installer-fcgi-mod/install.d/55tex.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +cat < " + PW=$(pwgen -s1 32) + if [ "$ROVID" = "" ]; then + ROVID="demo" + fi + cat "$MAYORDIR/config/$file.example" | sed -e "s/%SQLPW%/$PW/" -e "s/demo/${ROVID}/" > "$MAYORDIR/config/$file" + echo $file +fi + +echo -e "\n SQL file létrehozása... " +if [ ! -d $TMPDIR/mysql ]; then + mkdir -p $TMPDIR/mysql +fi +cd $TMPDIR/mysql +PDB=$(grep db $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") +USER=$(grep user $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") +PW=$(grep pw $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") + +cat $MAYORDIR/install/mayor-portal/mysql/mayor-portal.sql | sed \ + -e "s/%MYSQL_PORTAL_DB%/$PDB/g" \ + -e "s/%MYSQL_PORTAL_USER%/$USER/g" \ + -e "s/%MYSQL_PORTAL_PW%/$PW/g" > mayor-portal.sql + +DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +cat $MAYORDIR/install/mayor-portal/mysql/portal-init.sql | sed \ + -e "s/%MYSQL_PRIVATE_DB%/$DB/g" \ + -e "s/%MYSQL_PORTAL_DB%/$PDB/g" > portal-init.sql + +read -n 1 -p "Telepíthetem? (i/N)" -s DO +if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi +echo -e "\n" + +if [ "$MYSQLROOTPW" == "" ]; then + read -p " A mysql root jelszó -ha van- (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW +fi + +if [ "$MYSQLROOTPW" = "" ]; +then + MYSQLROOTPWSTR=""; +else + MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" +fi + + +cat /tmp/mysql/mayor-portal.sql /tmp/mysql/portal-init.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 + +read -n 1 -p "Tegyük a portál oldalt a rendszer kezdőlapjává minden hozzáférési szinten? (i/N)" -s DO +if [ "$DO" != "i" ]; then + echo -e "\nA portál oldalt nem teszem kezdőlappá.\n"; + cat <'portal', 'sub' => 'portal', 'f' => 'portal');/" $MAYORDIR/config/$file + echo ok + done +fi + +if [ "$ROVID" != "demo" ]; then + echo -e "\nEgyedi kezdőoldalak létrehozása:" + for policy in private public parent; do + echo -n " $policy " + for skin in classic pda; do + cp $MAYORDIR/www/policy/$policy/portal/portal/portal_demo.$skin.php $MAYORDIR/www/policy/$policy/portal/portal/portal_$ROVID.$skin.php + echo -n "... " + done + echo "ok" + done +fi + diff --git a/mayor-installer-fcgi-mod/log/mayor-installer.rev b/mayor-installer-fcgi-mod/log/mayor-installer.rev new file mode 100644 index 00000000..87ca4f07 --- /dev/null +++ b/mayor-installer-fcgi-mod/log/mayor-installer.rev @@ -0,0 +1 @@ +4284 diff --git a/mayor-installer-fcgi-mod/setup b/mayor-installer-fcgi-mod/setup new file mode 100755 index 00000000..0c523a89 --- /dev/null +++ b/mayor-installer-fcgi-mod/setup @@ -0,0 +1,48 @@ +#!/bin/bash +clear +echo "-------------------------------------------" +echo " MaYoR Setup " +echo "-------------------------------------------" + +MAYORDIR="/var/mayor" +TMPDIR="/tmp" +MYSQLROOTPW="" +VERSION="current" +export MAYORDIR +export TMPDIR +export MYSQLROOTPW +export VERSION +export MAYORUSER="mayor-web" + +echo -e "A MaYoR keretrendszer és elektronikus napló telepítője a továbbiakban +több lépésben, az egyes lépésekre jóváhagyást kérve fogja végrehajtani a +telepítés és konfigurálás lépéseit. + +A telepítő egy tipikus telepítés esetén alkalmazható, speciális igények esetén +célszerűbb az egyes lépéseket a telepítési útmutató alapján manuálisan végezni. + +Lehetőség van a Mayor, az apache2 úgynevezett mod_uexec/mod_fcgi alá történő telepítésére is.\n" + +read -n 1 -p "Folytatja? (i/N)" -s DO +if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi +echo -e "\n" + +read -n 1 -p "Telepítés: (H)agyományos vagy (F)cgi/suexec-módban? (s/H)" -s DO +if [ "$DO" != "h" ]; then echo " ok, mod_Suexec/mod_fcgid használata." + installer="fcgi_install.d" + export MAYORDIR="/home/$MAYORUSER/mayor" +else + installer="install.d" + echo " ok, Hagyományos módon."; fi + echo -e "\n" + + + +for f in $installer/* +do + echo -e "\n----------------------------------------------\n$f\nMAYORDIR:$MAYORDIR\nMAYORUSER:$MAYORUSER\n----------------------------------------------\n" + ./$f $@ + if [ "$?" == 255 ]; then echo "Fatális hiba! A telepítő kilép."; exit 255; fi; +done + +echo -e "MaYoR (c) setup\n" diff --git a/mayor-installer-fcgi/fcgi_install.d/01createhome.sh b/mayor-installer-fcgi/fcgi_install.d/01createhome.sh deleted file mode 100755 index bdb7398a..00000000 --- a/mayor-installer-fcgi/fcgi_install.d/01createhome.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# - -cat < (apache2=fcgid): <==IPC==> :php-értelmező_apache_gyermekprocesszként_külön_userként - - -FONTOS!! -A napló is ebből a könyvtárból fog futni, a /var/mayor/ egy symlink lesz -erre a könyvtárra. de ugyanúgy használható továbbra is, mint eddig. - -Például: - A felhasználó neve: mayor-web - A home könyvtára : /home/mayor-web/ - A mayor könyvtára : /home/mayor-web/mayor/ - A mayor mantés(pl): /home/mayor-web/mayor_backup/ - (Megj: a /var/mayor/ továbbra is használható.) - (/var/mayor/ --> /home/mayor-web/mayor/) - -A telepítés végén pedig mindez a >> ps auxf parancs kiadásával személetesebben is látszódik. -EOF - - -echo -e "A php értelmező felhasználója: $MAYORUSER" -read -n 1 -p "Létrehozhatom? (i/N) " -s DO -if [ "$DO" != "i" ]; then echo -e "\nA $MAYORUSER létrehozását kihagytam.\n"; exit 1; fi - -useradd -p "*" -m --home "/home/$MAYORUSER" --shell "/bin/false" --system "$MAYORUSER" -chage --mindays 0 --maxdays 99999 --warndays 7 "$MAYORUSER" -chfn --full-name "$MAYORUSER" "$MAYORUSER" -echo -e "A $MAYORUSER (rendszer)felhasználó hozzáadva.\n" - -echo -e "/home/$MAYORUSER/mayor és mayor_backup mappák létrehozása.\n" -mkdir -p "/home/$MAYORUSER/mayor_backup" -mkdir -p "/home/$MAYORUSER/mayor" - -echo -e "linkelés a /var/mayor könyvtárra.\n" -ln -s "/home/$MAYORUSER/mayor" "/var/mayor" - -echo -e "kész.\n\n" - - diff --git a/mayor-installer-fcgi/fcgi_install.d/05checkdeb.sh b/mayor-installer-fcgi/fcgi_install.d/05checkdeb.sh deleted file mode 100755 index 5b5e1828..00000000 --- a/mayor-installer-fcgi/fcgi_install.d/05checkdeb.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash -# -DEBIAN=false; -UBUNTU=false; -if [ $(which lsb_release || echo "notinstalled") == "notinstalled" ] -then - ISSUE=$(cat /etc/issue | cut -d " " -f 1) - if [ "x${ISSUE}" == "xDebian" ]; then - DEBIAN=true; - RELEASE=$(cat /etc/issue | cut -d " " -f 3) - elif [ "x${ISSUE}" == "xUbuntu" ]; then - UBUNTU=true; - RELEASE=$(cat /etc/issue | cut -d " " -f 2) - fi -else - DISTRIBUTOR=$(lsb_release -i -s) - RELEASE=$(lsb_release -r -s) - if [ "x${DISTRIBUTOR}" == "xDebian" ]; then - DEBIAN=true; - elif [ "x${DISTRIBUTOR}" == "xUbuntu" ]; then - UBUNTU=true; - fi -fi -echo "Debian:" ${DEBIAN} -echo "Ubuntu:" ${UBUNTU} -echo "Version:" ${RELEASE} - -TEST=$(grep contrib /etc/apt/sources.list) -if [ "$TEST" == "" ] -then - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "Az apt sources.list módosítása szükséges!" - if [ DEBIAN ]; then - echo "Debian Jessie (8) esetén például: - deb http://ftp.hu.debian.org/debian/ jessie main contrib non-free - deb http://security.debian.org/ jessie/updates main contrib non-free - deb http://ftp.hu.debian.org/debian/ jessie-updates main contrib non-free - -Debian 9 esetén például: - deb http://ftp.hu.debian.org/debian/ stretch main contrib non-free - deb http://security.debian.org/debian-security stretch/updates main contrib non-free - deb http://ftp.hu.debian.org/debian/ stretch-updates main contrib non-free - \n" - - read -n 1 -p "Hozzáadhatom? (egyelőre csak Debian9 esetén működik) (i/N)" -s DO - if [ "$DO" != "i" ]; then echo -e "\nA hozzáadást kihagytam.\n"; exit 255; fi - - if [[ "x${RELEASE}" =~ ^x9.* ]]; then - echo -e "#mayor miatt is: -deb http://ftp.hu.debian.org/debian/ stretch contrib non-free -deb http://security.debian.org/debian-security stretch/updates contrib non-free -deb http://ftp.hu.debian.org/debian/ stretch-updates contrib non-free" >> /etc/apt/sources.list - - fi - echo -e "\n ---- csomaglista frissítése ---- \n" - apt update ## frisítés - echo -e "\n ------------- kész ------------- \n" - - fi -# exit 255; -fi - -if [[ "x${RELEASE}" =~ ^x9.* ]] -then - PKGS="apache2 apache2-suexec-custom libapache2-mod-fcgid php-cgi php php-json php-mysql php-ldap php-mbstring php-mcrypt php-curl mariadb-server recode texlive texlive-fonts-extra texlive-latex-extra texlive-binaries texlive-xetex ntp wget ssl-cert ssh pwgen texlive-lang-european" -else - PKGS="apache2 apache2-suexec-custom libapache2-mod-fcgid php5-cgi php5 php5-json php5-mysqlnd php5-ldap php5-mcrypt php5-curl mysql-server recode texlive texlive-fonts-extra texlive-latex-extra texlive-binaries texlive-xetex ttf-mscorefonts-installer ntp wget ssl-cert ssh pwgen texlive-lang-european texlive-lang-hungarian" -fi - -if [ "$1" == "--no-deb" ]; then - exit 1 -fi - -cat </dev/null | sed 's/.*-\([^-]*\)\.tgz$/\1/' ) - -DO=n -if [ "$MENU" == '' ]; then - DO=i -else - echo " 0 Letöltés mindenképpen" - echo "${MENU}" | sed 's/.*-\([^-]*\)\.tgz$/\1/' | nl - read -n1 -p 'Melyiket telepítsem? ' SEL; echo - - if [ "$SEL" == 0 ]; then - DO=i - else - SELECT=$( echo "${MENU}" | sed -n ${SEL}p ) - - MAYORBASE="$TMPDIR/mayor-base-$SELECT.tgz" - MAYORNAPLO="$TMPDIR/mayor-naplo-$SELECT.tgz" - fi -fi - -if [ "$DO" == "i" ]; then - MAYORBASE="$TMPDIR/mayor-base-current.tgz" - MAYORNAPLO="$TMPDIR/mayor-naplo-current.tgz" - - echo -e "\nForrások letöltése:" - cd $TMPDIR - rm -f mayor-base-current.tgz - rm -f mayor-naplo-current.tgz - wget "http://www.mayor.hu/download/$VERSION/mayor-base-current.tgz" - wget "http://www.mayor.hu/download/$VERSION/mayor-naplo-current.tgz" -else - echo -e "\nA forráscsomagok letöltését kihagytam.\n" -fi - -read -n 1 -p "Telepítsem a forrás csomagokat? (i/N)" -s DO -if [ "$DO" != "i" ]; then echo -e "\nA forráscsomagok telepítését kihagytam.\n"; exit 1; fi - -echo -n -e "\nRendszer könyvtár: " -if [ ! -e $MAYORDIR ]; then - mkdir -p $MAYORDIR -fi -if [ ! -e "/var/mayor" ]; then - ln -s $MAYORDIR /var/mayor -fi -echo $MAYORDIR - -echo -e -n "Források kicsomagolása... " -cd $MAYORDIR -tar xfz "$MAYORBASE" -tar xfz "$MAYORNAPLO" -echo "ok." - diff --git a/mayor-installer-fcgi/fcgi_install.d/15createconfig.sh b/mayor-installer-fcgi/fcgi_install.d/15createconfig.sh deleted file mode 100755 index 74156932..00000000 --- a/mayor-installer-fcgi/fcgi_install.d/15createconfig.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# - -cat < " - PW=$(pwgen -s1 32) - cat "$MAYORDIR/config/$file.example" | sed s/%SQLPW%/$PW/ > "$MAYORDIR/config/$file" - echo $file - fi -done - -echo -n " module-naplo/config.php.example --> " -PW=$(pwgen -s1 32) -PWREAD=$(pwgen -s1 32) -if [ -e "$MAYORDIR/config/module-naplo/config.php" ]; then echo " module-naplo/config.php létezik."; else - cat "$MAYORDIR/config/module-naplo/config.php.example" | sed -e s/%SQLPW%/$PW/ -e s/%SQLPWREAD%/$PWREAD/ > "$MAYORDIR/config/module-naplo/config.php" - echo "module-naplo/config.php" -fi - -if [ -e "$MAYORDIR/config/skin-classic/naplo-config.php" ]; then echo " skin-classic/naplo-config.php létezik."; else - echo -n " skin-classic/naplo-config.php.example --> " - cp $MAYORDIR/config/skin-classic/naplo-config.php.example $MAYORDIR/config/skin-classic/naplo-config.php - echo "config/skin-classic/naplo-config.php" -fi - - -sed -e "s/\/var\/mayor/\/home\/$MAYORUSER\/mayor/g" -i "$MAYORDIR/config/main-config.php" diff --git a/mayor-installer-fcgi/fcgi_install.d/20mysql.sh b/mayor-installer-fcgi/fcgi_install.d/20mysql.sh deleted file mode 100755 index 7ae70bfb..00000000 --- a/mayor-installer-fcgi/fcgi_install.d/20mysql.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# - -cat < /etc/mysql/conf.d/utf8.cnf - -#cp -f $MAYORDIR/install/base/mysql/utf8.cnf /etc/mysql/conf.d -echo ok -/etc/init.d/mysql restart - -if [ "x${RELEASE}" == "x9" ] -then - echo -e "\nMariaDB/MySQL beállítások" - echo -n " futtatom a mysql_Secure_installation scriptet: " - mysql_secure_installation -fi diff --git a/mayor-installer-fcgi/fcgi_install.d/25apache.sh b/mayor-installer-fcgi/fcgi_install.d/25apache.sh deleted file mode 100755 index d2aa12c7..00000000 --- a/mayor-installer-fcgi/fcgi_install.d/25apache.sh +++ /dev/null @@ -1,254 +0,0 @@ -#!/bin/bash -# - -cat < /dev/null - echo ok -else - echo "már engedélyezett" -fi - echo -n " - ModReWrite engedélyezése ... " -if [ ! -e /etc/apache2/mods-enabled/rewrite.load ]; then - a2enmod rewrite > /dev/null - echo ok -else - echo "már engedélyezett" -fi - -echo -n " - mod_suexec engedélyezése ... " -if [ ! -e /etc/apache2/mods-enabled/suexec.load ]; then - a2enmod suexec > /dev/null - echo ok -else - echo "már engedélyezett" -fi - -echo -n " - mod_fcgid engedélyezése ... " -if [ ! -e /etc/apache2/mods-enabled/fcgid.load ]; then - a2enmod fcgid > /dev/null - echo ok -else - echo "már engedélyezett" -fi - -echo -n " - mod_actions engedélyezése ... " -if [ ! -e /etc/apache2/mods-enabled/actions.load ]; then - a2enmod actions > /dev/null - echo ok -else - echo "már engedélyezett" -fi - - -echo -n " - mod_php kikapcsolása (a www-data php értelmezője)" -if [ -e /etc/apache2/mods-enabled/php7.0.load ]; then - a2dismod php7.0 > /dev/null - echo ok -else - echo "nincs bekapcsolava" -fi - -echo -n " - mod_headers engedélyezése" -if [ ! -e /etc/apache2/mods-enabled/headers.load ]; then - a2enmod headers > /dev/null - echo ok -else - echo "nincs bekapcsolava" -fi - - -echo -n " - Apache2 mod_worker és mod_event, amíg a php nem lesz thread-safe. " -if [ -e /etc/apache2/mods-enabled/mpm_event.load ] || [ -e /etc/apache2/mods-enabled/mpm_worker.load ]; then - a2dismod mpm_event > /dev/null - a2dismod mpm_worker > /dev/null - a2enmod mpm_prefork > /dev/null - echo ok -else - echo "nincs bekapcsolava" -fi - -echo "ok." - - -echo -e " Apache2 konfiguráció létrehozása\n" -cat > /etc/apache2/sites-available/mayor_naplo.conf < - ServerName your.mayor.server.hu -# ServerAlias your.mayor.server.hu your.mayor.server.iskola.sulinet.hu - - - ServerAdmin webmaster@localhost - - SuexecUserGroup mayor-user mayor-user - DocumentRoot mayor-docroot - ScriptAlias /wbin/ mayor-web-bin - - AddHandler php-fcgi .php - Action php-fcgi /wbin/php7.fcgi - AddType application/x-httpd-php .php - - - FcgidProcessLifeTime 3600 - FcgidIOTimeout 320 - FcgidMaxRequestInMem 16777216 - FcgidMaxRequestLen 33554432 - FcgidBusyTimeout 600 -## FcgidOutputBufferSize 0 - FcgidIdleTimeout 400 - - -# Részletesebben: -# FcgidProcessLifeTime 3600 ##(seconds) A php max futási ideje (a (hagyományos) mod_php-nál is ennyi) -# FcgidIOTimeout 320 ##(seconds) A php generál valamit, elkldi a böngészőnek, vagy a böngésző küld adatot a php-nak, ennyi ideig tarthat. (pl: 120sec) -# FcgidMaxRequestInMem 16777216 ##(bytes) Amikor a böngésző küld adatokat a php-nak, ennyi megy a pufferbe. (16MB elég) -# FcgidMaxRequestLen 33554432 ##(bytes) Amikor a böngésző küld adatot a php-nak, az adat max hossza bájtokabn. (32MB elég) -# FcgidBusyTimeout 600 ##(seconds) A php max ennyi ideig gondolkozhat egy futáson/kérésen, ha túllépi, ki lesz lőve. -# FcgidOutputBufferSize 0 ##(bytes) Pufer, amikor a php generál valami adatot, és azt elküldené a böngészőnek. {ezt még át kéne nézni} -# FcgidIdleTimeout 400 ##(seconds) A php-értelmező ennyi pihenés után le lesz állítva.(**) -# ##(**) Figyelem! Itt a "php-értelmező" külön gyermekprocesszként fut, ami az oldal meglátogatásakor indul automatikusan, -# ## és FcgidIdleTimeout-nyi pihenés után magától leáll. - - IndexIgnore * - - - ## A php-csomagoló, és php.ini fájlok közvetlen elérésének tiltása - - Require all granted - - Require env REDIRECT_STATUS - - - Require all denied - - - Require all denied - - - - DirectoryIndex index.php index.html index.htm - - - Options FollowSymLinks - AllowOverride None - - - - Options -Indexes +FollowSymLinks +MultiViews - AllowOverride None - # Apache 2.2 # Order allow,deny - # Apache 2.2 # allow from all - # Apache 2.4 # Require all granted - = 2.3> - Require all granted - - - order allow,deny - allow from all - - RewriteEngine on - RewriteBase / - RewriteCond %{SERVER_PORT} ^80$ - RewriteCond %{THE_REQUEST} .*(policy=private|page=auth|page=password).* - RewriteRule (.*)$ https://%{HTTP_HOST}/$1 [L] - - - - SSLEngine On -# ## A gyenge titkosítások tiltása - SSLProtocol all -SSLv2 -SSLv3 -TLSv1 - SSLCertificateFile /etc/apache2/ssl/apache_mayor.pem -# # SSLCertificateFile /etc/apache2/ssl/crt/name-cert.pem -# # SSLCertificateKeyFile /etc/apache2/ssl/key/name-key.pem - - - - Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains" - - - - ErrorLog \${APACHE_LOG_DIR}/mayor_error.log - - # Possible values include: debug, info, notice, warn, error, crit, - # alert, emerg. - LogLevel info ssl:warn fcgid:debug - - CustomLog \${APACHE_LOG_DIR}/mayor_access.log combined - ServerSignature On - - -EOT - - - -SERVERNAME="" -while [ "$SERVERNAME" = "" ] -do - read -p " A web szerver teljes domain neve (pl: mayor.tesztsuli.hu): " SERVERNAME -done - -#cat $MAYORDIR/install/base/apache2/mayor.conf | sed "s/ServerName your.mayor.server.hu/ServerName $SERVERNAME/" > /etc/apache2/sites-available/mayor.conf - -# A 2.4-es apache esetén módosítani kell a konfig állományt! -APACHE_VERSION=$(dpkg -l apache2 | grep apache2 | tr -s ' ' | cut -d ' ' -f 3 | cut -d '-' -f 1 | sed 's/\..$//') - -echo -e " Apache2 finomhangolása\n" - -sed -e "s/ServerName your.mayor.server.hu/ServerName $SERVERNAME/g" -i /etc/apache2/sites-available/mayor_naplo.conf -sed -e "s/SuexecUserGroup mayor-user mayor-user/SuexecUserGroup $MAYORUSER $MAYORUSER/g" -i /etc/apache2/sites-available/mayor_naplo.conf -sed -e "s/DocumentRoot mayor-docroot/DocumentRoot \/home\/$MAYORUSER\/mayor\/www\/ /g" -i /etc/apache2/sites-available/mayor_naplo.conf -sed -e "s/ScriptAlias \/wbin\/ mayor-web-bin/ScriptAlias \/wbin\/ \/home\/$MAYORUSER\/mayor\/www-bin\/ /g" -i /etc/apache2/sites-available/mayor_naplo.conf -sed -e "s// /g" -i /etc/apache2/sites-available/mayor_naplo.conf -sed -e "s// /g" -i /etc/apache2/sites-available/mayor_naplo.conf - -echo -e " a suexec beállítása\n" -sed -e 's/\/var\/www/\/home\n\/var\/www/g' -i /etc/apache2/suexec/www-data - -echo " A php-csomagoló elkészítése" -mkdir -p "/home/$MAYORUSER/mayor/www-bin/" - -csomagolo="#!/bin/sh \n exec /usr/bin/php-cgi7.0 " -echo -e $csomagolo > "/home/$MAYORUSER/mayor/www-bin/php7.fcgi" -chmod +x "/home/$MAYORUSER/mayor/www-bin/php7.fcgi" - -echo " A php.ini beszerzése" -cp "/etc/php/7.0/cgi/php.ini" "/home/$MAYORUSER/mayor/www-bin/php.ini" -chown -R "$MAYORUSER:$MAYORUSER" "/home/$MAYORUSER/mayor/www-bin" - - -if [ ! -e /etc/apache2/sites-enabled/mayor_naplo.conf ]; then - echo " A mayor site engedélyezése" - a2ensite mayor_naplo.conf > /dev/null -fi - -echo " A web-szerver újraindítása" -/etc/init.d/apache2 restart diff --git a/mayor-installer-fcgi/fcgi_install.d/30php.sh b/mayor-installer-fcgi/fcgi_install.d/30php.sh deleted file mode 100755 index 3e4545a2..00000000 --- a/mayor-installer-fcgi/fcgi_install.d/30php.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# - -cat < mayor-login.sql -DB=$(grep db $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -USER=$(grep user $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -PW=$(grep pw $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -cat $MAYORDIR/install/base/mysql/mayor-auth.sql | sed -e "s/%MYSQL_AUTH_DB%/$DB/g" -e "s/%MYSQL_AUTH_USER%/$USER/g" \ - -e "s/%MYSQL_AUTH_PW%/$PW/g" > mayor-parent.sql -DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -USER=$(grep 'mysql user' $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -PW=$(grep pw $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -cat $MAYORDIR/install/base/mysql/mayor-auth.sql | sed -e "s/%MYSQL_AUTH_DB%/$DB/g" -e "s/%MYSQL_AUTH_USER%/$USER/g" \ - -e "s/%MYSQL_AUTH_PW%/$PW/g" > mayor-private.sql -DB=$(grep db $MAYORDIR/config/module-naplo/config.php | grep naplo_base | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -USER=$(egrep 'userWrite.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -USERREAD=$(egrep 'userRead.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -PW=$(egrep 'pwWrite.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -PWREAD=$(egrep 'pwRead.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -cat $MAYORDIR/install/module-naplo/mysql/base.sql | sed -e "s/%MYSQL_NAPLO_DB%/$DB/g" -e "s/%MYSQL_NAPLO_USER%/$USER/g" \ - -e "s/%MYSQL_NAPLO_PW%/$PW/g" -e "s/%MYSQL_NAPLO_USER_READ%/$USERREAD/g" \ - -e "s/%MYSQL_NAPLO_PW_READ%/$PWREAD/g" > base.sql -DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") - -cat $MAYORDIR/install/base/mysql/private-users.sql | sed -e "s/%MYSQL_PRIVATE_DB%/$DB/g" > private-users.sql -cat $MAYORDIR/install/module-naplo/mysql/naplo-users.sql | sed -e "s/%MYSQL_PRIVATE_DB%/$DB/g" > naplo-users.sql - -echo " A létrejött sql fileok:" -FILES=$(ls *.sql) -for f in $FILES -do - echo " * ${f}"; -done; -read -n 1 -p "Telepíthetem? (i/N)" -s DO -if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi -echo -e "\n" - -read -p " A mysql root jelszó (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW - -if [ ! -e $MAYORDIR/config/main.conf ]; then - cat $MAYORDIR/config/main.conf.example | sed s/%SQLPW%/$MYSQLROOTPW/ > $MAYORDIR/config/main.conf - chmod 600 $MAYORDIR/config/main.conf -fi - -if [ "$MYSQLROOTPW" = "" ]; -then - MYSQLROOTPWSTR=""; -else - MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" -fi - -cat /tmp/mysql/mayor-login.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/mayor-parent.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/mayor-private.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/base.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/private-users.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/naplo-users.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 - -echo -e "\n" -echo "A telepítés végeztével beléphetsz a webes felületen! -========================================================= - user: mayoradmin -========================================================= - jelszó: jelszo -========================================================= -" diff --git a/mayor-installer-fcgi/fcgi_install.d/40binary.sh b/mayor-installer-fcgi/fcgi_install.d/40binary.sh deleted file mode 100755 index 33acc60d..00000000 --- a/mayor-installer-fcgi/fcgi_install.d/40binary.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# - -cat < $TMPDIR/mysql/intezmeny.sql - -insert into $DB.intezmeny (OMKod, rovidNev, nev, alapertelmezett) VALUES ('$OMKOD','$ROVID','$INTEZMENYNEV',1); -create database intezmeny_$ROVID character set utf8 collate utf8_hungarian_ci; -grant select,execute on intezmeny_$ROVID.* to '$USERREAD'@'localhost'; -grant all on intezmeny_$ROVID.* to '$USER'@'localhost'; -use intezmeny_$ROVID; - -EOF - -if [ "$MYSQLROOTPW" == "" ]; then - read -p " A mysql root jelszó -ha van!- (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW -fi -#Ezt miért is akarom kiírni? -#echo $MYSQLROOTPW - a jelszó -if [ "$MYSQLROOTPW" = "" ]; -then - MYSQLROOTPWSTR=""; -else - MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" -fi - -cat $TMPDIR/mysql/intezmeny.sql $MAYORDIR/install/module-naplo/mysql/intezmeny.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 $INTEZMENYDB diff --git a/mayor-installer-fcgi/fcgi_install.d/50linker.sh b/mayor-installer-fcgi/fcgi_install.d/50linker.sh deleted file mode 100755 index bd4910a9..00000000 --- a/mayor-installer-fcgi/fcgi_install.d/50linker.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -# -cat < $MAYORDIR/www/policy/$POLICY/$file" - ln -s $MAYORDIR/www/policy/private/$file $MAYORDIR/www/policy/$POLICY/$file - else - echo " Hiányzó file: $MAYORDIR/www/policy/private/$file" - fi - else - echo " [OK] A file már létezik: " $file - fi - done - done -done diff --git a/mayor-installer-fcgi/fcgi_install.d/55tex.sh b/mayor-installer-fcgi/fcgi_install.d/55tex.sh deleted file mode 100755 index 87bcbc5f..00000000 --- a/mayor-installer-fcgi/fcgi_install.d/55tex.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -cat < " - PW=$(pwgen -s1 32) - if [ "$ROVID" = "" ]; then - ROVID="demo" - fi - cat "$MAYORDIR/config/$file.example" | sed -e "s/%SQLPW%/$PW/" -e "s/demo/${ROVID}/" > "$MAYORDIR/config/$file" - echo $file -fi - -echo -e "\n SQL file létrehozása... " -if [ ! -d $TMPDIR/mysql ]; then - mkdir -p $TMPDIR/mysql -fi -cd $TMPDIR/mysql -PDB=$(grep db $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") -USER=$(grep user $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") -PW=$(grep pw $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") - -cat $MAYORDIR/install/mayor-portal/mysql/mayor-portal.sql | sed \ - -e "s/%MYSQL_PORTAL_DB%/$PDB/g" \ - -e "s/%MYSQL_PORTAL_USER%/$USER/g" \ - -e "s/%MYSQL_PORTAL_PW%/$PW/g" > mayor-portal.sql - -DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -cat $MAYORDIR/install/mayor-portal/mysql/portal-init.sql | sed \ - -e "s/%MYSQL_PRIVATE_DB%/$DB/g" \ - -e "s/%MYSQL_PORTAL_DB%/$PDB/g" > portal-init.sql - -read -n 1 -p "Telepíthetem? (i/N)" -s DO -if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi -echo -e "\n" - -if [ "$MYSQLROOTPW" == "" ]; then - read -p " A mysql root jelszó -ha van- (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW -fi - -if [ "$MYSQLROOTPW" = "" ]; -then - MYSQLROOTPWSTR=""; -else - MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" -fi - - -cat /tmp/mysql/mayor-portal.sql /tmp/mysql/portal-init.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 - -read -n 1 -p "Tegyük a portál oldalt a rendszer kezdőlapjává minden hozzáférési szinten? (i/N)" -s DO -if [ "$DO" != "i" ]; then - echo -e "\nA portál oldalt nem teszem kezdőlappá.\n"; - cat <'portal', 'sub' => 'portal', 'f' => 'portal');/" $MAYORDIR/config/$file - echo ok - done -fi - -if [ "$ROVID" != "demo" ]; then - echo -e "\nEgyedi kezdőoldalak létrehozása:" - for policy in private public parent; do - echo -n " $policy " - for skin in classic pda; do - cp $MAYORDIR/www/policy/$policy/portal/portal/portal_demo.$skin.php $MAYORDIR/www/policy/$policy/portal/portal/portal_$ROVID.$skin.php - echo -n "... " - done - echo "ok" - done -fi - diff --git a/mayor-installer-fcgi/fcgi_install.d/90chown.sh b/mayor-installer-fcgi/fcgi_install.d/90chown.sh deleted file mode 100755 index 1e090128..00000000 --- a/mayor-installer-fcgi/fcgi_install.d/90chown.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -echo -e "A könyvtárak jogosultságainak beállítása\n\n" -read -n 1 -p "beállíthatom? (i/N)" -s DO -if [ "$DO" != "i" ]; then echo -e "\nNem.\n"; exit 1; fi - - -if [ $MAYORUSER == "" ] || [ $MAYORDIR == "" ]; then echo -e "A MAYOR(DIR/USER) változó üres! .....kilépek\n" ; exit 1 ; fi - -chown -R "$MAYORUSER:$MAYORUSER" /home/$MAYORUSER/ ## Ez esetben a MAYORDIR a /home/xxx/mayor-ra mutat - -find /home/$MAYORUSER/ -type f -print0 | xargs -0 chmod 0644 -find /home/$MAYORUSER/ -type d -print0 | xargs -0 chmod 0751 -find /home/$MAYORUSER/ -name '*.php' -print0 | xargs -0 chmod 0640 -find /home/$MAYORUSER/mayor/ -name '*.sh' -print0 | xargs -0 chmod 0600 -find /home/$MAYORUSER/mayor/bin/ -name '*.sh' -print0 | xargs -0 chown root:root -find /home/$MAYORUSER/mayor/ -name '*.conf' -print0 | xargs -0 chmod 0600 - -# a csomagoló jogainak visszaállítása -chmod -R 600 "/home/$MAYORUSER/mayor/www-bin/" -chmod +x "/home/$MAYORUSER/mayor/www-bin/php7.fcgi" - -## de azért idemásolom az eredetit is, biztos-ami-biztos -chmod 700 $MAYORDIR/config/ -# A main.conf védelme -chown root:root $MAYORDIR/config/main.conf -chmod 600 $MAYORDIR/config/main.conf - - -echo -e "...kész.\n" \ No newline at end of file diff --git a/mayor-installer-fcgi/fcgi_install.d/99end.sh b/mayor-installer-fcgi/fcgi_install.d/99end.sh deleted file mode 100755 index fab52dc8..00000000 --- a/mayor-installer-fcgi/fcgi_install.d/99end.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -echo -e "-------------------------------------------------\n" -echo -e "Telepítés vége. \n\n" - - - diff --git a/mayor-installer-fcgi/install.d/05checkdeb.sh b/mayor-installer-fcgi/install.d/05checkdeb.sh deleted file mode 100755 index 2488d60a..00000000 --- a/mayor-installer-fcgi/install.d/05checkdeb.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash -# -DEBIAN=false; -UBUNTU=false; -if [ $(which lsb_release || echo "notinstalled") == "notinstalled" ] -then - ISSUE=$(cat /etc/issue | cut -d " " -f 1) - if [ "x${ISSUE}" == "xDebian" ]; then - DEBIAN=true; - RELEASE=$(cat /etc/issue | cut -d " " -f 3) - elif [ "x${ISSUE}" == "xUbuntu" ]; then - UBUNTU=true; - RELEASE=$(cat /etc/issue | cut -d " " -f 2) - fi -else - DISTRIBUTOR=$(lsb_release -i -s) - RELEASE=$(lsb_release -r -s) - if [ "x${DISTRIBUTOR}" == "xDebian" ]; then - DEBIAN=true; - elif [ "x${DISTRIBUTOR}" == "xUbuntu" ]; then - UBUNTU=true; - fi -fi -echo "Debian:" ${DEBIAN} -echo "Ubuntu:" ${UBUNTU} -echo "Version:" ${RELEASE} - -TEST=$(grep contrib /etc/apt/sources.list) -if [ "$TEST" == "" ] -then - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "Az apt sources.list módosítása szükséges!" - if [ DEBIAN ]; then - echo "Debian Jessie (8) esetén például: - deb http://ftp.hu.debian.org/debian/ jessie main contrib non-free - deb http://security.debian.org/ jessie/updates main contrib non-free - deb http://ftp.hu.debian.org/debian/ jessie-updates main contrib non-free - -Debian 9 esetén például: - deb http://ftp.hu.debian.org/debian/ stretch main contrib non-free - deb http://security.debian.org/debian-security stretch/updates main contrib non-free - deb http://ftp.hu.debian.org/debian/ stretch-updates main contrib non-free - \n" - - read -n 1 -p "Hozzáadhatom? (egyelőre csak Debian9 esetén működik) (i/N)" -s DO - if [ "$DO" != "i" ]; then echo -e "\nA hozzáadást kihagytam.\n"; exit 255; fi - - if [[ "x${RELEASE}" =~ ^x9.* ]]; then - echo -e "#mayor miatt is: -deb http://ftp.hu.debian.org/debian/ stretch contrib non-free -deb http://security.debian.org/debian-security stretch/updates contrib non-free -deb http://ftp.hu.debian.org/debian/ stretch-updates contrib non-free" >> /etc/apt/sources.list - - fi - echo -e "\n ---- csomaglista frissítése ---- \n" - apt update ## frisítés - echo -e "\n ------------- kész ------------- \n" - - fi -# exit 255; -fi - -if [[ "x${RELEASE}" =~ ^x9.* ]] -then - PKGS="apache2 php libapache2-mod-php php-json php-mysql php-ldap php-mbstring php-mcrypt php-curl mariadb-server recode texlive texlive-fonts-extra texlive-latex-extra texlive-binaries texlive-xetex ntp wget ssl-cert ssh pwgen texlive-lang-european" -else - PKGS="apache2 php5 libapache2-mod-php5 php5-json php5-mysqlnd php5-ldap php5-mcrypt php5-curl mysql-server recode texlive texlive-fonts-extra texlive-latex-extra texlive-binaries texlive-xetex ttf-mscorefonts-installer ntp wget ssl-cert ssh pwgen texlive-lang-european texlive-lang-hungarian" -fi - -if [ "$1" == "--no-deb" ]; then - exit 1 -fi - -cat </dev/null | sed 's/.*-\([^-]*\)\.tgz$/\1/' ) - -DO=n -if [ "$MENU" == '' ]; then - DO=i -else - echo " 0 Letöltés mindenképpen" - echo "${MENU}" | sed 's/.*-\([^-]*\)\.tgz$/\1/' | nl - read -n1 -p 'Melyiket telepítsem? ' SEL; echo - - if [ "$SEL" == 0 ]; then - DO=i - else - SELECT=$( echo "${MENU}" | sed -n ${SEL}p ) - - MAYORBASE="$TMPDIR/mayor-base-$SELECT.tgz" - MAYORNAPLO="$TMPDIR/mayor-naplo-$SELECT.tgz" - fi -fi - -if [ "$DO" == "i" ]; then - MAYORBASE="$TMPDIR/mayor-base-current.tgz" - MAYORNAPLO="$TMPDIR/mayor-naplo-current.tgz" - - echo -e "\nForrások letöltése:" - cd $TMPDIR - rm -f mayor-base-current.tgz - rm -f mayor-naplo-current.tgz - wget "http://www.mayor.hu/download/$VERSION/mayor-base-current.tgz" - wget "http://www.mayor.hu/download/$VERSION/mayor-naplo-current.tgz" -else - echo -e "\nA forráscsomagok letöltését kihagytam.\n" -fi - -read -n 1 -p "Telepítsem a forrás csomagokat? (i/N)" -s DO -if [ "$DO" != "i" ]; then echo -e "\nA forráscsomagok telepítését kihagytam.\n"; exit 1; fi - -echo -n -e "\nRendszer könyvtár: " -if [ ! -e $MAYORDIR ]; then - mkdir -p $MAYORDIR -fi -if [ ! -e "/var/mayor" ]; then - ln -s $MAYORDIR /var/mayor -fi -echo $MAYORDIR - -echo -e -n "Források kicsomagolása... " -cd $MAYORDIR -tar xfz "$MAYORBASE" -tar xfz "$MAYORNAPLO" -echo "ok." - diff --git a/mayor-installer-fcgi/install.d/15createconfig.sh b/mayor-installer-fcgi/install.d/15createconfig.sh deleted file mode 100755 index 8d035fe1..00000000 --- a/mayor-installer-fcgi/install.d/15createconfig.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# - -cat < " - PW=(pwgen -s1 32) - cat "$MAYORDIR/config/$file.example" | sed s/%SQLPW%/$PW/ > "$MAYORDIR/config/$file" - echo $file - fi -done - -echo -n " module-naplo/config.php.example --> " -PW=$(pwgen -s1 32) -PWREAD=$(pwgen -s1 32) -if [ -e "$MAYORDIR/config/module-naplo/config.php" ]; then echo " module-naplo/config.php létezik."; else - cat "$MAYORDIR/config/module-naplo/config.php.example" | sed -e s/%SQLPW%/$PW/ -e s/%SQLPWREAD%/$PWREAD/ > "$MAYORDIR/config/module-naplo/config.php" - echo "module-naplo/config.php" -fi - -if [ -e "$MAYORDIR/config/skin-classic/naplo-config.php" ]; then echo " skin-classic/naplo-config.php létezik."; else - echo -n " skin-classic/naplo-config.php.example --> " - cp $MAYORDIR/config/skin-classic/naplo-config.php.example $MAYORDIR/config/skin-classic/naplo-config.php - echo "config/skin-classic/naplo-config.php" -fi diff --git a/mayor-installer-fcgi/install.d/20mysql.sh b/mayor-installer-fcgi/install.d/20mysql.sh deleted file mode 100755 index 2979f728..00000000 --- a/mayor-installer-fcgi/install.d/20mysql.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# - -cat < /dev/null - echo ok -else - echo "már engedélyezett" -fi - echo -n " - ModReWrite engedélyezése ... " -if [ ! -e /etc/apache2/mods-enabled/rewrite.load ]; then - a2enmod rewrite > /dev/null - echo ok -else - echo "már engedélyezett" -fi -echo "ok." - -SERVERNAME="" -while [ "$SERVERNAME" = "" ] -do - read -p " A web szerver teljes domain neve (pl: mayor.tesztsuli.hu): " SERVERNAME -done - -#cat $MAYORDIR/install/base/apache2/mayor.conf | sed "s/ServerName your.mayor.server.hu/ServerName $SERVERNAME/" > /etc/apache2/sites-available/mayor.conf - -# A 2.4-es apache esetén módosítani kell a konfig állományt! -APACHE_VERSION=$(dpkg -l apache2 | grep apache2 | tr -s ' ' | cut -d ' ' -f 3 | cut -d '-' -f 1 | sed 's/\..$//') -cat $MAYORDIR/install/base/apache2/mayor.conf | sed \ - -e "s/ServerName your.mayor.server.hu/ServerName $SERVERNAME/" > /etc/apache2/sites-available/mayor.conf - - -if [ ! -e /etc/apache2/sites-enabled/mayor.conf ]; then - echo " A mayor site engedélyezése" - a2ensite mayor.conf > /dev/null -fi - -echo " A web-szerver újraindítása" -/etc/init.d/apache2 restart diff --git a/mayor-installer-fcgi/install.d/30php.sh b/mayor-installer-fcgi/install.d/30php.sh deleted file mode 100755 index 49000c68..00000000 --- a/mayor-installer-fcgi/install.d/30php.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# - -cat < /etc/php5/apache2/php.ini -echo 256M - -echo " Az web szerver újraindítása" -/etc/init.d/apache2 restart - diff --git a/mayor-installer-fcgi/install.d/35createdatabases.sh b/mayor-installer-fcgi/install.d/35createdatabases.sh deleted file mode 100755 index 718ca3c2..00000000 --- a/mayor-installer-fcgi/install.d/35createdatabases.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash -# - -cat < mayor-login.sql -DB=$(grep db $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -USER=$(grep user $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -PW=$(grep pw $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -cat $MAYORDIR/install/base/mysql/mayor-auth.sql | sed -e "s/%MYSQL_AUTH_DB%/$DB/g" -e "s/%MYSQL_AUTH_USER%/$USER/g" \ - -e "s/%MYSQL_AUTH_PW%/$PW/g" > mayor-parent.sql -DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -USER=$(grep 'mysql user' $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -PW=$(grep pw $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -cat $MAYORDIR/install/base/mysql/mayor-auth.sql | sed -e "s/%MYSQL_AUTH_DB%/$DB/g" -e "s/%MYSQL_AUTH_USER%/$USER/g" \ - -e "s/%MYSQL_AUTH_PW%/$PW/g" > mayor-private.sql -DB=$(grep db $MAYORDIR/config/module-naplo/config.php | grep naplo_base | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -USER=$(egrep 'userWrite.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -USERREAD=$(egrep 'userRead.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -PW=$(egrep 'pwWrite.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -PWREAD=$(egrep 'pwRead.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -cat $MAYORDIR/install/module-naplo/mysql/base.sql | sed -e "s/%MYSQL_NAPLO_DB%/$DB/g" -e "s/%MYSQL_NAPLO_USER%/$USER/g" \ - -e "s/%MYSQL_NAPLO_PW%/$PW/g" -e "s/%MYSQL_NAPLO_USER_READ%/$USERREAD/g" \ - -e "s/%MYSQL_NAPLO_PW_READ%/$PWREAD/g" > base.sql -DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") - -cat $MAYORDIR/install/base/mysql/private-users.sql | sed -e "s/%MYSQL_PRIVATE_DB%/$DB/g" > private-users.sql -cat $MAYORDIR/install/module-naplo/mysql/naplo-users.sql | sed -e "s/%MYSQL_PRIVATE_DB%/$DB/g" > naplo-users.sql - -echo " A létrejött sql fileok:" -FILES=$(ls *.sql) -for f in $FILES -do - echo " * ${f}"; -done; -read -n 1 -p "Telepíthetem? (i/N)" -s DO -if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi -echo -e "\n" - -read -p " A mysql root jelszó (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW - - -if [ ! -e $MAYORDIR/config/main.conf ]; then - cat $MAYORDIR/config/main.conf.example | sed s/%SQLPW%/$MYSQLROOTPW/ > $MAYORDIR/config/main.conf -# BDIR=$(echo $MAYORDIR | sed -e 's:\/:\\\/:g') -# sed -e "s/BASEDIR=\"\/var\/mayor\"/BASEDIR=\"$BDIR\"/g" -i $MAYORDIR/config/main.conf - chmod 600 $MAYORDIR/config/main.conf -fi - -if [ "$MYSQLROOTPW" = "" ]; -then - MYSQLROOTPWSTR=""; -else - MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" -fi - -cat /tmp/mysql/mayor-login.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/mayor-parent.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/mayor-private.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/base.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/private-users.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/naplo-users.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 - -echo -e "\n" -echo "A telepítés végeztével beléphetsz a webes felületen! -========================================================= - user: mayoradmin -========================================================= - jelszó: jelszo -========================================================= -" diff --git a/mayor-installer-fcgi/install.d/40binary.sh b/mayor-installer-fcgi/install.d/40binary.sh deleted file mode 100755 index e0f0598b..00000000 --- a/mayor-installer-fcgi/install.d/40binary.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# - -cat < $TMPDIR/mysql/intezmeny.sql - -insert into $DB.intezmeny (OMKod, rovidNev, nev, alapertelmezett) VALUES ('$OMKOD','$ROVID','$INTEZMENYNEV',1); -create database intezmeny_$ROVID character set utf8 collate utf8_hungarian_ci; -grant select,execute on intezmeny_$ROVID.* to '$USERREAD'@'localhost'; -grant all on intezmeny_$ROVID.* to '$USER'@'localhost'; -use intezmeny_$ROVID; - -EOF - -if [ "$MYSQLROOTPW" == "" ]; then - read -p " A mysql root jelszó -ha van!- (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW -fi -#Ezt miért is akarom kiírni? -#echo $MYSQLROOTPW - a jelszó -if [ "$MYSQLROOTPW" = "" ]; -then - MYSQLROOTPWSTR=""; -else - MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" -fi - -cat $TMPDIR/mysql/intezmeny.sql $MAYORDIR/install/module-naplo/mysql/intezmeny.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 $INTEZMENYDB diff --git a/mayor-installer-fcgi/install.d/50linker.sh b/mayor-installer-fcgi/install.d/50linker.sh deleted file mode 100755 index 73887902..00000000 --- a/mayor-installer-fcgi/install.d/50linker.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -# -cat < $MAYORDIR/www/policy/$POLICY/$file" - ln -s $MAYORDIR/www/policy/private/$file $MAYORDIR/www/policy/$POLICY/$file - else - echo " Hiányzó file: $MAYORDIR/www/policy/private/$file" - fi - else - echo " [OK] A file már létezik: " $file - fi - done - done -done diff --git a/mayor-installer-fcgi/install.d/55tex.sh b/mayor-installer-fcgi/install.d/55tex.sh deleted file mode 100755 index 87bcbc5f..00000000 --- a/mayor-installer-fcgi/install.d/55tex.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -cat < " - PW=$(pwgen -s1 32) - if [ "$ROVID" = "" ]; then - ROVID="demo" - fi - cat "$MAYORDIR/config/$file.example" | sed -e "s/%SQLPW%/$PW/" -e "s/demo/${ROVID}/" > "$MAYORDIR/config/$file" - echo $file -fi - -echo -e "\n SQL file létrehozása... " -if [ ! -d $TMPDIR/mysql ]; then - mkdir -p $TMPDIR/mysql -fi -cd $TMPDIR/mysql -PDB=$(grep db $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") -USER=$(grep user $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") -PW=$(grep pw $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") - -cat $MAYORDIR/install/mayor-portal/mysql/mayor-portal.sql | sed \ - -e "s/%MYSQL_PORTAL_DB%/$PDB/g" \ - -e "s/%MYSQL_PORTAL_USER%/$USER/g" \ - -e "s/%MYSQL_PORTAL_PW%/$PW/g" > mayor-portal.sql - -DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -cat $MAYORDIR/install/mayor-portal/mysql/portal-init.sql | sed \ - -e "s/%MYSQL_PRIVATE_DB%/$DB/g" \ - -e "s/%MYSQL_PORTAL_DB%/$PDB/g" > portal-init.sql - -read -n 1 -p "Telepíthetem? (i/N)" -s DO -if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi -echo -e "\n" - -if [ "$MYSQLROOTPW" == "" ]; then - read -p " A mysql root jelszó -ha van- (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW -fi - -if [ "$MYSQLROOTPW" = "" ]; -then - MYSQLROOTPWSTR=""; -else - MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" -fi - - -cat /tmp/mysql/mayor-portal.sql /tmp/mysql/portal-init.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 - -read -n 1 -p "Tegyük a portál oldalt a rendszer kezdőlapjává minden hozzáférési szinten? (i/N)" -s DO -if [ "$DO" != "i" ]; then - echo -e "\nA portál oldalt nem teszem kezdőlappá.\n"; - cat <'portal', 'sub' => 'portal', 'f' => 'portal');/" $MAYORDIR/config/$file - echo ok - done -fi - -if [ "$ROVID" != "demo" ]; then - echo -e "\nEgyedi kezdőoldalak létrehozása:" - for policy in private public parent; do - echo -n " $policy " - for skin in classic pda; do - cp $MAYORDIR/www/policy/$policy/portal/portal/portal_demo.$skin.php $MAYORDIR/www/policy/$policy/portal/portal/portal_$ROVID.$skin.php - echo -n "... " - done - echo "ok" - done -fi - diff --git a/mayor-installer-fcgi/log/mayor-installer.rev b/mayor-installer-fcgi/log/mayor-installer.rev deleted file mode 100644 index 87ca4f07..00000000 --- a/mayor-installer-fcgi/log/mayor-installer.rev +++ /dev/null @@ -1 +0,0 @@ -4284 diff --git a/mayor-installer-fcgi/setup b/mayor-installer-fcgi/setup deleted file mode 100755 index 0c523a89..00000000 --- a/mayor-installer-fcgi/setup +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -clear -echo "-------------------------------------------" -echo " MaYoR Setup " -echo "-------------------------------------------" - -MAYORDIR="/var/mayor" -TMPDIR="/tmp" -MYSQLROOTPW="" -VERSION="current" -export MAYORDIR -export TMPDIR -export MYSQLROOTPW -export VERSION -export MAYORUSER="mayor-web" - -echo -e "A MaYoR keretrendszer és elektronikus napló telepítője a továbbiakban -több lépésben, az egyes lépésekre jóváhagyást kérve fogja végrehajtani a -telepítés és konfigurálás lépéseit. - -A telepítő egy tipikus telepítés esetén alkalmazható, speciális igények esetén -célszerűbb az egyes lépéseket a telepítési útmutató alapján manuálisan végezni. - -Lehetőség van a Mayor, az apache2 úgynevezett mod_uexec/mod_fcgi alá történő telepítésére is.\n" - -read -n 1 -p "Folytatja? (i/N)" -s DO -if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi -echo -e "\n" - -read -n 1 -p "Telepítés: (H)agyományos vagy (F)cgi/suexec-módban? (s/H)" -s DO -if [ "$DO" != "h" ]; then echo " ok, mod_Suexec/mod_fcgid használata." - installer="fcgi_install.d" - export MAYORDIR="/home/$MAYORUSER/mayor" -else - installer="install.d" - echo " ok, Hagyományos módon."; fi - echo -e "\n" - - - -for f in $installer/* -do - echo -e "\n----------------------------------------------\n$f\nMAYORDIR:$MAYORDIR\nMAYORUSER:$MAYORUSER\n----------------------------------------------\n" - ./$f $@ - if [ "$?" == 255 ]; then echo "Fatális hiba! A telepítő kilép."; exit 255; fi; -done - -echo -e "MaYoR (c) setup\n" diff --git a/mayor-installer-mod/install.d/05checkdeb.sh b/mayor-installer-mod/install.d/05checkdeb.sh new file mode 100755 index 00000000..2488d60a --- /dev/null +++ b/mayor-installer-mod/install.d/05checkdeb.sh @@ -0,0 +1,106 @@ +#!/bin/bash +# +DEBIAN=false; +UBUNTU=false; +if [ $(which lsb_release || echo "notinstalled") == "notinstalled" ] +then + ISSUE=$(cat /etc/issue | cut -d " " -f 1) + if [ "x${ISSUE}" == "xDebian" ]; then + DEBIAN=true; + RELEASE=$(cat /etc/issue | cut -d " " -f 3) + elif [ "x${ISSUE}" == "xUbuntu" ]; then + UBUNTU=true; + RELEASE=$(cat /etc/issue | cut -d " " -f 2) + fi +else + DISTRIBUTOR=$(lsb_release -i -s) + RELEASE=$(lsb_release -r -s) + if [ "x${DISTRIBUTOR}" == "xDebian" ]; then + DEBIAN=true; + elif [ "x${DISTRIBUTOR}" == "xUbuntu" ]; then + UBUNTU=true; + fi +fi +echo "Debian:" ${DEBIAN} +echo "Ubuntu:" ${UBUNTU} +echo "Version:" ${RELEASE} + +TEST=$(grep contrib /etc/apt/sources.list) +if [ "$TEST" == "" ] +then + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "Az apt sources.list módosítása szükséges!" + if [ DEBIAN ]; then + echo "Debian Jessie (8) esetén például: + deb http://ftp.hu.debian.org/debian/ jessie main contrib non-free + deb http://security.debian.org/ jessie/updates main contrib non-free + deb http://ftp.hu.debian.org/debian/ jessie-updates main contrib non-free + +Debian 9 esetén például: + deb http://ftp.hu.debian.org/debian/ stretch main contrib non-free + deb http://security.debian.org/debian-security stretch/updates main contrib non-free + deb http://ftp.hu.debian.org/debian/ stretch-updates main contrib non-free + \n" + + read -n 1 -p "Hozzáadhatom? (egyelőre csak Debian9 esetén működik) (i/N)" -s DO + if [ "$DO" != "i" ]; then echo -e "\nA hozzáadást kihagytam.\n"; exit 255; fi + + if [[ "x${RELEASE}" =~ ^x9.* ]]; then + echo -e "#mayor miatt is: +deb http://ftp.hu.debian.org/debian/ stretch contrib non-free +deb http://security.debian.org/debian-security stretch/updates contrib non-free +deb http://ftp.hu.debian.org/debian/ stretch-updates contrib non-free" >> /etc/apt/sources.list + + fi + echo -e "\n ---- csomaglista frissítése ---- \n" + apt update ## frisítés + echo -e "\n ------------- kész ------------- \n" + + fi +# exit 255; +fi + +if [[ "x${RELEASE}" =~ ^x9.* ]] +then + PKGS="apache2 php libapache2-mod-php php-json php-mysql php-ldap php-mbstring php-mcrypt php-curl mariadb-server recode texlive texlive-fonts-extra texlive-latex-extra texlive-binaries texlive-xetex ntp wget ssl-cert ssh pwgen texlive-lang-european" +else + PKGS="apache2 php5 libapache2-mod-php5 php5-json php5-mysqlnd php5-ldap php5-mcrypt php5-curl mysql-server recode texlive texlive-fonts-extra texlive-latex-extra texlive-binaries texlive-xetex ttf-mscorefonts-installer ntp wget ssl-cert ssh pwgen texlive-lang-european texlive-lang-hungarian" +fi + +if [ "$1" == "--no-deb" ]; then + exit 1 +fi + +cat </dev/null | sed 's/.*-\([^-]*\)\.tgz$/\1/' ) + +DO=n +if [ "$MENU" == '' ]; then + DO=i +else + echo " 0 Letöltés mindenképpen" + echo "${MENU}" | sed 's/.*-\([^-]*\)\.tgz$/\1/' | nl + read -n1 -p 'Melyiket telepítsem? ' SEL; echo + + if [ "$SEL" == 0 ]; then + DO=i + else + SELECT=$( echo "${MENU}" | sed -n ${SEL}p ) + + MAYORBASE="$TMPDIR/mayor-base-$SELECT.tgz" + MAYORNAPLO="$TMPDIR/mayor-naplo-$SELECT.tgz" + fi +fi + +if [ "$DO" == "i" ]; then + MAYORBASE="$TMPDIR/mayor-base-current.tgz" + MAYORNAPLO="$TMPDIR/mayor-naplo-current.tgz" + + echo -e "\nForrások letöltése:" + cd $TMPDIR + rm -f mayor-base-current.tgz + rm -f mayor-naplo-current.tgz + wget "http://www.mayor.hu/download/$VERSION/mayor-base-current.tgz" + wget "http://www.mayor.hu/download/$VERSION/mayor-naplo-current.tgz" +else + echo -e "\nA forráscsomagok letöltését kihagytam.\n" +fi + +read -n 1 -p "Telepítsem a forrás csomagokat? (i/N)" -s DO +if [ "$DO" != "i" ]; then echo -e "\nA forráscsomagok telepítését kihagytam.\n"; exit 1; fi + +echo -n -e "\nRendszer könyvtár: " +if [ ! -e $MAYORDIR ]; then + mkdir -p $MAYORDIR +fi +if [ ! -e "/var/mayor" ]; then + ln -s $MAYORDIR /var/mayor +fi +echo $MAYORDIR + +echo -e -n "Források kicsomagolása... " +cd $MAYORDIR +tar xfz "$MAYORBASE" +tar xfz "$MAYORNAPLO" +echo "ok." + diff --git a/mayor-installer-mod/install.d/15createconfig.sh b/mayor-installer-mod/install.d/15createconfig.sh new file mode 100755 index 00000000..8d035fe1 --- /dev/null +++ b/mayor-installer-mod/install.d/15createconfig.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# + +cat < " + PW=(pwgen -s1 32) + cat "$MAYORDIR/config/$file.example" | sed s/%SQLPW%/$PW/ > "$MAYORDIR/config/$file" + echo $file + fi +done + +echo -n " module-naplo/config.php.example --> " +PW=$(pwgen -s1 32) +PWREAD=$(pwgen -s1 32) +if [ -e "$MAYORDIR/config/module-naplo/config.php" ]; then echo " module-naplo/config.php létezik."; else + cat "$MAYORDIR/config/module-naplo/config.php.example" | sed -e s/%SQLPW%/$PW/ -e s/%SQLPWREAD%/$PWREAD/ > "$MAYORDIR/config/module-naplo/config.php" + echo "module-naplo/config.php" +fi + +if [ -e "$MAYORDIR/config/skin-classic/naplo-config.php" ]; then echo " skin-classic/naplo-config.php létezik."; else + echo -n " skin-classic/naplo-config.php.example --> " + cp $MAYORDIR/config/skin-classic/naplo-config.php.example $MAYORDIR/config/skin-classic/naplo-config.php + echo "config/skin-classic/naplo-config.php" +fi diff --git a/mayor-installer-mod/install.d/20mysql.sh b/mayor-installer-mod/install.d/20mysql.sh new file mode 100755 index 00000000..2979f728 --- /dev/null +++ b/mayor-installer-mod/install.d/20mysql.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# + +cat < /dev/null + echo ok +else + echo "már engedélyezett" +fi + echo -n " - ModReWrite engedélyezése ... " +if [ ! -e /etc/apache2/mods-enabled/rewrite.load ]; then + a2enmod rewrite > /dev/null + echo ok +else + echo "már engedélyezett" +fi +echo "ok." + +SERVERNAME="" +while [ "$SERVERNAME" = "" ] +do + read -p " A web szerver teljes domain neve (pl: mayor.tesztsuli.hu): " SERVERNAME +done + +#cat $MAYORDIR/install/base/apache2/mayor.conf | sed "s/ServerName your.mayor.server.hu/ServerName $SERVERNAME/" > /etc/apache2/sites-available/mayor.conf + +# A 2.4-es apache esetén módosítani kell a konfig állományt! +APACHE_VERSION=$(dpkg -l apache2 | grep apache2 | tr -s ' ' | cut -d ' ' -f 3 | cut -d '-' -f 1 | sed 's/\..$//') +cat $MAYORDIR/install/base/apache2/mayor.conf | sed \ + -e "s/ServerName your.mayor.server.hu/ServerName $SERVERNAME/" > /etc/apache2/sites-available/mayor.conf + + +if [ ! -e /etc/apache2/sites-enabled/mayor.conf ]; then + echo " A mayor site engedélyezése" + a2ensite mayor.conf > /dev/null +fi + +echo " A web-szerver újraindítása" +/etc/init.d/apache2 restart diff --git a/mayor-installer-mod/install.d/30php.sh b/mayor-installer-mod/install.d/30php.sh new file mode 100755 index 00000000..5f751018 --- /dev/null +++ b/mayor-installer-mod/install.d/30php.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# + +cat < /etc/php/7.0/apache2/php.ini + echo -e "256M" + +else + + echo -n " A PHP memória limit beállítása: " + if [ ! -e /etc/php5/apache2/php.ini.mayor ]; then + cp /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini.mayor + fi + + cat /etc/php5/apache2/php.ini.mayor | sed "s/memory_limit/memory_limit = 256M ; old value: /" > /etc/php5/apache2/php.ini + echo -e "256M" +fi + +echo " Az web szerver újraindítása" +/etc/init.d/apache2 restart + diff --git a/mayor-installer-mod/install.d/35createdatabases.sh b/mayor-installer-mod/install.d/35createdatabases.sh new file mode 100755 index 00000000..718ca3c2 --- /dev/null +++ b/mayor-installer-mod/install.d/35createdatabases.sh @@ -0,0 +1,132 @@ +#!/bin/bash +# + +cat < mayor-login.sql +DB=$(grep db $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +USER=$(grep user $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +PW=$(grep pw $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +cat $MAYORDIR/install/base/mysql/mayor-auth.sql | sed -e "s/%MYSQL_AUTH_DB%/$DB/g" -e "s/%MYSQL_AUTH_USER%/$USER/g" \ + -e "s/%MYSQL_AUTH_PW%/$PW/g" > mayor-parent.sql +DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +USER=$(grep 'mysql user' $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +PW=$(grep pw $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +cat $MAYORDIR/install/base/mysql/mayor-auth.sql | sed -e "s/%MYSQL_AUTH_DB%/$DB/g" -e "s/%MYSQL_AUTH_USER%/$USER/g" \ + -e "s/%MYSQL_AUTH_PW%/$PW/g" > mayor-private.sql +DB=$(grep db $MAYORDIR/config/module-naplo/config.php | grep naplo_base | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +USER=$(egrep 'userWrite.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +USERREAD=$(egrep 'userRead.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +PW=$(egrep 'pwWrite.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +PWREAD=$(egrep 'pwRead.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +cat $MAYORDIR/install/module-naplo/mysql/base.sql | sed -e "s/%MYSQL_NAPLO_DB%/$DB/g" -e "s/%MYSQL_NAPLO_USER%/$USER/g" \ + -e "s/%MYSQL_NAPLO_PW%/$PW/g" -e "s/%MYSQL_NAPLO_USER_READ%/$USERREAD/g" \ + -e "s/%MYSQL_NAPLO_PW_READ%/$PWREAD/g" > base.sql +DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") + +cat $MAYORDIR/install/base/mysql/private-users.sql | sed -e "s/%MYSQL_PRIVATE_DB%/$DB/g" > private-users.sql +cat $MAYORDIR/install/module-naplo/mysql/naplo-users.sql | sed -e "s/%MYSQL_PRIVATE_DB%/$DB/g" > naplo-users.sql + +echo " A létrejött sql fileok:" +FILES=$(ls *.sql) +for f in $FILES +do + echo " * ${f}"; +done; +read -n 1 -p "Telepíthetem? (i/N)" -s DO +if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi +echo -e "\n" + +read -p " A mysql root jelszó (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW + + +if [ ! -e $MAYORDIR/config/main.conf ]; then + cat $MAYORDIR/config/main.conf.example | sed s/%SQLPW%/$MYSQLROOTPW/ > $MAYORDIR/config/main.conf +# BDIR=$(echo $MAYORDIR | sed -e 's:\/:\\\/:g') +# sed -e "s/BASEDIR=\"\/var\/mayor\"/BASEDIR=\"$BDIR\"/g" -i $MAYORDIR/config/main.conf + chmod 600 $MAYORDIR/config/main.conf +fi + +if [ "$MYSQLROOTPW" = "" ]; +then + MYSQLROOTPWSTR=""; +else + MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" +fi + +cat /tmp/mysql/mayor-login.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/mayor-parent.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/mayor-private.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/base.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/private-users.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 +cat /tmp/mysql/naplo-users.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 + +echo -e "\n" +echo "A telepítés végeztével beléphetsz a webes felületen! +========================================================= + user: mayoradmin +========================================================= + jelszó: jelszo +========================================================= +" diff --git a/mayor-installer-mod/install.d/40binary.sh b/mayor-installer-mod/install.d/40binary.sh new file mode 100755 index 00000000..e0f0598b --- /dev/null +++ b/mayor-installer-mod/install.d/40binary.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# + +cat < $TMPDIR/mysql/intezmeny.sql + +insert into $DB.intezmeny (OMKod, rovidNev, nev, alapertelmezett) VALUES ('$OMKOD','$ROVID','$INTEZMENYNEV',1); +create database intezmeny_$ROVID character set utf8 collate utf8_hungarian_ci; +grant select,execute on intezmeny_$ROVID.* to '$USERREAD'@'localhost'; +grant all on intezmeny_$ROVID.* to '$USER'@'localhost'; +use intezmeny_$ROVID; + +EOF + +if [ "$MYSQLROOTPW" == "" ]; then + read -p " A mysql root jelszó -ha van!- (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW +fi +#Ezt miért is akarom kiírni? +#echo $MYSQLROOTPW - a jelszó +if [ "$MYSQLROOTPW" = "" ]; +then + MYSQLROOTPWSTR=""; +else + MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" +fi + +cat $TMPDIR/mysql/intezmeny.sql $MAYORDIR/install/module-naplo/mysql/intezmeny.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 $INTEZMENYDB diff --git a/mayor-installer-mod/install.d/50linker.sh b/mayor-installer-mod/install.d/50linker.sh new file mode 100755 index 00000000..73887902 --- /dev/null +++ b/mayor-installer-mod/install.d/50linker.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +cat < $MAYORDIR/www/policy/$POLICY/$file" + ln -s $MAYORDIR/www/policy/private/$file $MAYORDIR/www/policy/$POLICY/$file + else + echo " Hiányzó file: $MAYORDIR/www/policy/private/$file" + fi + else + echo " [OK] A file már létezik: " $file + fi + done + done +done diff --git a/mayor-installer-mod/install.d/55tex.sh b/mayor-installer-mod/install.d/55tex.sh new file mode 100755 index 00000000..87bcbc5f --- /dev/null +++ b/mayor-installer-mod/install.d/55tex.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +cat < " + PW=$(pwgen -s1 32) + if [ "$ROVID" = "" ]; then + ROVID="demo" + fi + cat "$MAYORDIR/config/$file.example" | sed -e "s/%SQLPW%/$PW/" -e "s/demo/${ROVID}/" > "$MAYORDIR/config/$file" + echo $file +fi + +echo -e "\n SQL file létrehozása... " +if [ ! -d $TMPDIR/mysql ]; then + mkdir -p $TMPDIR/mysql +fi +cd $TMPDIR/mysql +PDB=$(grep db $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") +USER=$(grep user $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") +PW=$(grep pw $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") + +cat $MAYORDIR/install/mayor-portal/mysql/mayor-portal.sql | sed \ + -e "s/%MYSQL_PORTAL_DB%/$PDB/g" \ + -e "s/%MYSQL_PORTAL_USER%/$USER/g" \ + -e "s/%MYSQL_PORTAL_PW%/$PW/g" > mayor-portal.sql + +DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") +cat $MAYORDIR/install/mayor-portal/mysql/portal-init.sql | sed \ + -e "s/%MYSQL_PRIVATE_DB%/$DB/g" \ + -e "s/%MYSQL_PORTAL_DB%/$PDB/g" > portal-init.sql + +read -n 1 -p "Telepíthetem? (i/N)" -s DO +if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi +echo -e "\n" + +if [ "$MYSQLROOTPW" == "" ]; then + read -p " A mysql root jelszó -ha van- (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW +fi + +if [ "$MYSQLROOTPW" = "" ]; +then + MYSQLROOTPWSTR=""; +else + MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" +fi + + +cat /tmp/mysql/mayor-portal.sql /tmp/mysql/portal-init.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 + +read -n 1 -p "Tegyük a portál oldalt a rendszer kezdőlapjává minden hozzáférési szinten? (i/N)" -s DO +if [ "$DO" != "i" ]; then + echo -e "\nA portál oldalt nem teszem kezdőlappá.\n"; + cat <'portal', 'sub' => 'portal', 'f' => 'portal');/" $MAYORDIR/config/$file + echo ok + done +fi + +if [ "$ROVID" != "demo" ]; then + echo -e "\nEgyedi kezdőoldalak létrehozása:" + for policy in private public parent; do + echo -n " $policy " + for skin in classic pda; do + cp $MAYORDIR/www/policy/$policy/portal/portal/portal_demo.$skin.php $MAYORDIR/www/policy/$policy/portal/portal/portal_$ROVID.$skin.php + echo -n "... " + done + echo "ok" + done +fi + diff --git a/mayor-installer-mod/log/mayor-installer.rev b/mayor-installer-mod/log/mayor-installer.rev new file mode 100644 index 00000000..87ca4f07 --- /dev/null +++ b/mayor-installer-mod/log/mayor-installer.rev @@ -0,0 +1 @@ +4284 diff --git a/mayor-installer-mod/setup b/mayor-installer-mod/setup new file mode 100755 index 00000000..3c13a155 --- /dev/null +++ b/mayor-installer-mod/setup @@ -0,0 +1,34 @@ +#!/bin/bash +clear +echo "-------------------------------------------" +echo " MaYoR Setup " +echo "-------------------------------------------" + +MAYORDIR="/var/mayor" +TMPDIR="/tmp" +MYSQLROOTPW="" +VERSION="current" +export MAYORDIR +export TMPDIR +export MYSQLROOTPW +export VERSION + +echo -e "A MaYoR keretrendszer és elektronikus napló telepítője a továbbiakban +több lépésben, az egyes lépésekre jóváhagyást kérve fogja végrehajtani a +telepítés és konfigurálás lépéseit. + +A telepítő egy tipikus telepítés esetén alkalmazható, speciális igények esetén +célszerűbb az egyes lépéseket a telepítési útmutató alapján manuálisan végezni.\n" + +read -n 1 -p "Folytatja? (i/N)" -s DO +if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi +echo -e "\n" + +for f in install.d/* +do + echo -e "\n----------------------------------------------\n$f\n----------------------------------------------\n" + ./$f $@ + if [ "$?" == 255 ]; then echo "Fatális hiba! A telepítő kilép."; exit 255; fi; +done + +echo -e "MaYoR (c) setup\n" diff --git a/mayor-installer/install.d/05checkdeb.sh b/mayor-installer/install.d/05checkdeb.sh deleted file mode 100755 index 2488d60a..00000000 --- a/mayor-installer/install.d/05checkdeb.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash -# -DEBIAN=false; -UBUNTU=false; -if [ $(which lsb_release || echo "notinstalled") == "notinstalled" ] -then - ISSUE=$(cat /etc/issue | cut -d " " -f 1) - if [ "x${ISSUE}" == "xDebian" ]; then - DEBIAN=true; - RELEASE=$(cat /etc/issue | cut -d " " -f 3) - elif [ "x${ISSUE}" == "xUbuntu" ]; then - UBUNTU=true; - RELEASE=$(cat /etc/issue | cut -d " " -f 2) - fi -else - DISTRIBUTOR=$(lsb_release -i -s) - RELEASE=$(lsb_release -r -s) - if [ "x${DISTRIBUTOR}" == "xDebian" ]; then - DEBIAN=true; - elif [ "x${DISTRIBUTOR}" == "xUbuntu" ]; then - UBUNTU=true; - fi -fi -echo "Debian:" ${DEBIAN} -echo "Ubuntu:" ${UBUNTU} -echo "Version:" ${RELEASE} - -TEST=$(grep contrib /etc/apt/sources.list) -if [ "$TEST" == "" ] -then - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "Az apt sources.list módosítása szükséges!" - if [ DEBIAN ]; then - echo "Debian Jessie (8) esetén például: - deb http://ftp.hu.debian.org/debian/ jessie main contrib non-free - deb http://security.debian.org/ jessie/updates main contrib non-free - deb http://ftp.hu.debian.org/debian/ jessie-updates main contrib non-free - -Debian 9 esetén például: - deb http://ftp.hu.debian.org/debian/ stretch main contrib non-free - deb http://security.debian.org/debian-security stretch/updates main contrib non-free - deb http://ftp.hu.debian.org/debian/ stretch-updates main contrib non-free - \n" - - read -n 1 -p "Hozzáadhatom? (egyelőre csak Debian9 esetén működik) (i/N)" -s DO - if [ "$DO" != "i" ]; then echo -e "\nA hozzáadást kihagytam.\n"; exit 255; fi - - if [[ "x${RELEASE}" =~ ^x9.* ]]; then - echo -e "#mayor miatt is: -deb http://ftp.hu.debian.org/debian/ stretch contrib non-free -deb http://security.debian.org/debian-security stretch/updates contrib non-free -deb http://ftp.hu.debian.org/debian/ stretch-updates contrib non-free" >> /etc/apt/sources.list - - fi - echo -e "\n ---- csomaglista frissítése ---- \n" - apt update ## frisítés - echo -e "\n ------------- kész ------------- \n" - - fi -# exit 255; -fi - -if [[ "x${RELEASE}" =~ ^x9.* ]] -then - PKGS="apache2 php libapache2-mod-php php-json php-mysql php-ldap php-mbstring php-mcrypt php-curl mariadb-server recode texlive texlive-fonts-extra texlive-latex-extra texlive-binaries texlive-xetex ntp wget ssl-cert ssh pwgen texlive-lang-european" -else - PKGS="apache2 php5 libapache2-mod-php5 php5-json php5-mysqlnd php5-ldap php5-mcrypt php5-curl mysql-server recode texlive texlive-fonts-extra texlive-latex-extra texlive-binaries texlive-xetex ttf-mscorefonts-installer ntp wget ssl-cert ssh pwgen texlive-lang-european texlive-lang-hungarian" -fi - -if [ "$1" == "--no-deb" ]; then - exit 1 -fi - -cat </dev/null | sed 's/.*-\([^-]*\)\.tgz$/\1/' ) - -DO=n -if [ "$MENU" == '' ]; then - DO=i -else - echo " 0 Letöltés mindenképpen" - echo "${MENU}" | sed 's/.*-\([^-]*\)\.tgz$/\1/' | nl - read -n1 -p 'Melyiket telepítsem? ' SEL; echo - - if [ "$SEL" == 0 ]; then - DO=i - else - SELECT=$( echo "${MENU}" | sed -n ${SEL}p ) - - MAYORBASE="$TMPDIR/mayor-base-$SELECT.tgz" - MAYORNAPLO="$TMPDIR/mayor-naplo-$SELECT.tgz" - fi -fi - -if [ "$DO" == "i" ]; then - MAYORBASE="$TMPDIR/mayor-base-current.tgz" - MAYORNAPLO="$TMPDIR/mayor-naplo-current.tgz" - - echo -e "\nForrások letöltése:" - cd $TMPDIR - rm -f mayor-base-current.tgz - rm -f mayor-naplo-current.tgz - wget "http://www.mayor.hu/download/$VERSION/mayor-base-current.tgz" - wget "http://www.mayor.hu/download/$VERSION/mayor-naplo-current.tgz" -else - echo -e "\nA forráscsomagok letöltését kihagytam.\n" -fi - -read -n 1 -p "Telepítsem a forrás csomagokat? (i/N)" -s DO -if [ "$DO" != "i" ]; then echo -e "\nA forráscsomagok telepítését kihagytam.\n"; exit 1; fi - -echo -n -e "\nRendszer könyvtár: " -if [ ! -e $MAYORDIR ]; then - mkdir -p $MAYORDIR -fi -if [ ! -e "/var/mayor" ]; then - ln -s $MAYORDIR /var/mayor -fi -echo $MAYORDIR - -echo -e -n "Források kicsomagolása... " -cd $MAYORDIR -tar xfz "$MAYORBASE" -tar xfz "$MAYORNAPLO" -echo "ok." - diff --git a/mayor-installer/install.d/15createconfig.sh b/mayor-installer/install.d/15createconfig.sh deleted file mode 100755 index 8d035fe1..00000000 --- a/mayor-installer/install.d/15createconfig.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# - -cat < " - PW=(pwgen -s1 32) - cat "$MAYORDIR/config/$file.example" | sed s/%SQLPW%/$PW/ > "$MAYORDIR/config/$file" - echo $file - fi -done - -echo -n " module-naplo/config.php.example --> " -PW=$(pwgen -s1 32) -PWREAD=$(pwgen -s1 32) -if [ -e "$MAYORDIR/config/module-naplo/config.php" ]; then echo " module-naplo/config.php létezik."; else - cat "$MAYORDIR/config/module-naplo/config.php.example" | sed -e s/%SQLPW%/$PW/ -e s/%SQLPWREAD%/$PWREAD/ > "$MAYORDIR/config/module-naplo/config.php" - echo "module-naplo/config.php" -fi - -if [ -e "$MAYORDIR/config/skin-classic/naplo-config.php" ]; then echo " skin-classic/naplo-config.php létezik."; else - echo -n " skin-classic/naplo-config.php.example --> " - cp $MAYORDIR/config/skin-classic/naplo-config.php.example $MAYORDIR/config/skin-classic/naplo-config.php - echo "config/skin-classic/naplo-config.php" -fi diff --git a/mayor-installer/install.d/20mysql.sh b/mayor-installer/install.d/20mysql.sh deleted file mode 100755 index 2979f728..00000000 --- a/mayor-installer/install.d/20mysql.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# - -cat < /dev/null - echo ok -else - echo "már engedélyezett" -fi - echo -n " - ModReWrite engedélyezése ... " -if [ ! -e /etc/apache2/mods-enabled/rewrite.load ]; then - a2enmod rewrite > /dev/null - echo ok -else - echo "már engedélyezett" -fi -echo "ok." - -SERVERNAME="" -while [ "$SERVERNAME" = "" ] -do - read -p " A web szerver teljes domain neve (pl: mayor.tesztsuli.hu): " SERVERNAME -done - -#cat $MAYORDIR/install/base/apache2/mayor.conf | sed "s/ServerName your.mayor.server.hu/ServerName $SERVERNAME/" > /etc/apache2/sites-available/mayor.conf - -# A 2.4-es apache esetén módosítani kell a konfig állományt! -APACHE_VERSION=$(dpkg -l apache2 | grep apache2 | tr -s ' ' | cut -d ' ' -f 3 | cut -d '-' -f 1 | sed 's/\..$//') -cat $MAYORDIR/install/base/apache2/mayor.conf | sed \ - -e "s/ServerName your.mayor.server.hu/ServerName $SERVERNAME/" > /etc/apache2/sites-available/mayor.conf - - -if [ ! -e /etc/apache2/sites-enabled/mayor.conf ]; then - echo " A mayor site engedélyezése" - a2ensite mayor.conf > /dev/null -fi - -echo " A web-szerver újraindítása" -/etc/init.d/apache2 restart diff --git a/mayor-installer/install.d/30php.sh b/mayor-installer/install.d/30php.sh deleted file mode 100755 index 5f751018..00000000 --- a/mayor-installer/install.d/30php.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# - -cat < /etc/php/7.0/apache2/php.ini - echo -e "256M" - -else - - echo -n " A PHP memória limit beállítása: " - if [ ! -e /etc/php5/apache2/php.ini.mayor ]; then - cp /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini.mayor - fi - - cat /etc/php5/apache2/php.ini.mayor | sed "s/memory_limit/memory_limit = 256M ; old value: /" > /etc/php5/apache2/php.ini - echo -e "256M" -fi - -echo " Az web szerver újraindítása" -/etc/init.d/apache2 restart - diff --git a/mayor-installer/install.d/35createdatabases.sh b/mayor-installer/install.d/35createdatabases.sh deleted file mode 100755 index 718ca3c2..00000000 --- a/mayor-installer/install.d/35createdatabases.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash -# - -cat < mayor-login.sql -DB=$(grep db $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -USER=$(grep user $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -PW=$(grep pw $MAYORDIR/config/parent-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -cat $MAYORDIR/install/base/mysql/mayor-auth.sql | sed -e "s/%MYSQL_AUTH_DB%/$DB/g" -e "s/%MYSQL_AUTH_USER%/$USER/g" \ - -e "s/%MYSQL_AUTH_PW%/$PW/g" > mayor-parent.sql -DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -USER=$(grep 'mysql user' $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -PW=$(grep pw $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -cat $MAYORDIR/install/base/mysql/mayor-auth.sql | sed -e "s/%MYSQL_AUTH_DB%/$DB/g" -e "s/%MYSQL_AUTH_USER%/$USER/g" \ - -e "s/%MYSQL_AUTH_PW%/$PW/g" > mayor-private.sql -DB=$(grep db $MAYORDIR/config/module-naplo/config.php | grep naplo_base | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -USER=$(egrep 'userWrite.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -USERREAD=$(egrep 'userRead.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -PW=$(egrep 'pwWrite.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -PWREAD=$(egrep 'pwRead.*=' $MAYORDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -cat $MAYORDIR/install/module-naplo/mysql/base.sql | sed -e "s/%MYSQL_NAPLO_DB%/$DB/g" -e "s/%MYSQL_NAPLO_USER%/$USER/g" \ - -e "s/%MYSQL_NAPLO_PW%/$PW/g" -e "s/%MYSQL_NAPLO_USER_READ%/$USERREAD/g" \ - -e "s/%MYSQL_NAPLO_PW_READ%/$PWREAD/g" > base.sql -DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") - -cat $MAYORDIR/install/base/mysql/private-users.sql | sed -e "s/%MYSQL_PRIVATE_DB%/$DB/g" > private-users.sql -cat $MAYORDIR/install/module-naplo/mysql/naplo-users.sql | sed -e "s/%MYSQL_PRIVATE_DB%/$DB/g" > naplo-users.sql - -echo " A létrejött sql fileok:" -FILES=$(ls *.sql) -for f in $FILES -do - echo " * ${f}"; -done; -read -n 1 -p "Telepíthetem? (i/N)" -s DO -if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi -echo -e "\n" - -read -p " A mysql root jelszó (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW - - -if [ ! -e $MAYORDIR/config/main.conf ]; then - cat $MAYORDIR/config/main.conf.example | sed s/%SQLPW%/$MYSQLROOTPW/ > $MAYORDIR/config/main.conf -# BDIR=$(echo $MAYORDIR | sed -e 's:\/:\\\/:g') -# sed -e "s/BASEDIR=\"\/var\/mayor\"/BASEDIR=\"$BDIR\"/g" -i $MAYORDIR/config/main.conf - chmod 600 $MAYORDIR/config/main.conf -fi - -if [ "$MYSQLROOTPW" = "" ]; -then - MYSQLROOTPWSTR=""; -else - MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" -fi - -cat /tmp/mysql/mayor-login.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/mayor-parent.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/mayor-private.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/base.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/private-users.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 -cat /tmp/mysql/naplo-users.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 - -echo -e "\n" -echo "A telepítés végeztével beléphetsz a webes felületen! -========================================================= - user: mayoradmin -========================================================= - jelszó: jelszo -========================================================= -" diff --git a/mayor-installer/install.d/40binary.sh b/mayor-installer/install.d/40binary.sh deleted file mode 100755 index e0f0598b..00000000 --- a/mayor-installer/install.d/40binary.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# - -cat < $TMPDIR/mysql/intezmeny.sql - -insert into $DB.intezmeny (OMKod, rovidNev, nev, alapertelmezett) VALUES ('$OMKOD','$ROVID','$INTEZMENYNEV',1); -create database intezmeny_$ROVID character set utf8 collate utf8_hungarian_ci; -grant select,execute on intezmeny_$ROVID.* to '$USERREAD'@'localhost'; -grant all on intezmeny_$ROVID.* to '$USER'@'localhost'; -use intezmeny_$ROVID; - -EOF - -if [ "$MYSQLROOTPW" == "" ]; then - read -p " A mysql root jelszó -ha van!- (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW -fi -#Ezt miért is akarom kiírni? -#echo $MYSQLROOTPW - a jelszó -if [ "$MYSQLROOTPW" = "" ]; -then - MYSQLROOTPWSTR=""; -else - MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" -fi - -cat $TMPDIR/mysql/intezmeny.sql $MAYORDIR/install/module-naplo/mysql/intezmeny.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 $INTEZMENYDB diff --git a/mayor-installer/install.d/50linker.sh b/mayor-installer/install.d/50linker.sh deleted file mode 100755 index 73887902..00000000 --- a/mayor-installer/install.d/50linker.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -# -cat < $MAYORDIR/www/policy/$POLICY/$file" - ln -s $MAYORDIR/www/policy/private/$file $MAYORDIR/www/policy/$POLICY/$file - else - echo " Hiányzó file: $MAYORDIR/www/policy/private/$file" - fi - else - echo " [OK] A file már létezik: " $file - fi - done - done -done diff --git a/mayor-installer/install.d/55tex.sh b/mayor-installer/install.d/55tex.sh deleted file mode 100755 index 87bcbc5f..00000000 --- a/mayor-installer/install.d/55tex.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -cat < " - PW=$(pwgen -s1 32) - if [ "$ROVID" = "" ]; then - ROVID="demo" - fi - cat "$MAYORDIR/config/$file.example" | sed -e "s/%SQLPW%/$PW/" -e "s/demo/${ROVID}/" > "$MAYORDIR/config/$file" - echo $file -fi - -echo -e "\n SQL file létrehozása... " -if [ ! -d $TMPDIR/mysql ]; then - mkdir -p $TMPDIR/mysql -fi -cd $TMPDIR/mysql -PDB=$(grep db $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") -USER=$(grep user $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") -PW=$(grep pw $MAYORDIR/config/$file | sed -e "s/.*=\ *['\"]//g" -e "s/['\"];//g") - -cat $MAYORDIR/install/mayor-portal/mysql/mayor-portal.sql | sed \ - -e "s/%MYSQL_PORTAL_DB%/$PDB/g" \ - -e "s/%MYSQL_PORTAL_USER%/$USER/g" \ - -e "s/%MYSQL_PORTAL_PW%/$PW/g" > mayor-portal.sql - -DB=$(grep db $MAYORDIR/config/private-conf.php | sed -e "s/^.*>\ *['|\"]//g" -e "s/['|\"],//g") -cat $MAYORDIR/install/mayor-portal/mysql/portal-init.sql | sed \ - -e "s/%MYSQL_PRIVATE_DB%/$DB/g" \ - -e "s/%MYSQL_PORTAL_DB%/$PDB/g" > portal-init.sql - -read -n 1 -p "Telepíthetem? (i/N)" -s DO -if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi -echo -e "\n" - -if [ "$MYSQLROOTPW" == "" ]; then - read -p " A mysql root jelszó -ha van- (a begépelt szöveg nem látszik!): " -s MYSQLROOTPW -fi - -if [ "$MYSQLROOTPW" = "" ]; -then - MYSQLROOTPWSTR=""; -else - MYSQLROOTPWSTR="-p$MYSQLROOTPW --user=root" -fi - - -cat /tmp/mysql/mayor-portal.sql /tmp/mysql/portal-init.sql | mysql $MYSQLROOTPWSTR --default-character-set=utf8 - -read -n 1 -p "Tegyük a portál oldalt a rendszer kezdőlapjává minden hozzáférési szinten? (i/N)" -s DO -if [ "$DO" != "i" ]; then - echo -e "\nA portál oldalt nem teszem kezdőlappá.\n"; - cat <'portal', 'sub' => 'portal', 'f' => 'portal');/" $MAYORDIR/config/$file - echo ok - done -fi - -if [ "$ROVID" != "demo" ]; then - echo -e "\nEgyedi kezdőoldalak létrehozása:" - for policy in private public parent; do - echo -n " $policy " - for skin in classic pda; do - cp $MAYORDIR/www/policy/$policy/portal/portal/portal_demo.$skin.php $MAYORDIR/www/policy/$policy/portal/portal/portal_$ROVID.$skin.php - echo -n "... " - done - echo "ok" - done -fi - diff --git a/mayor-installer/log/mayor-installer.rev b/mayor-installer/log/mayor-installer.rev deleted file mode 100644 index 87ca4f07..00000000 --- a/mayor-installer/log/mayor-installer.rev +++ /dev/null @@ -1 +0,0 @@ -4284 diff --git a/mayor-installer/setup b/mayor-installer/setup deleted file mode 100755 index 3c13a155..00000000 --- a/mayor-installer/setup +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -clear -echo "-------------------------------------------" -echo " MaYoR Setup " -echo "-------------------------------------------" - -MAYORDIR="/var/mayor" -TMPDIR="/tmp" -MYSQLROOTPW="" -VERSION="current" -export MAYORDIR -export TMPDIR -export MYSQLROOTPW -export VERSION - -echo -e "A MaYoR keretrendszer és elektronikus napló telepítője a továbbiakban -több lépésben, az egyes lépésekre jóváhagyást kérve fogja végrehajtani a -telepítés és konfigurálás lépéseit. - -A telepítő egy tipikus telepítés esetén alkalmazható, speciális igények esetén -célszerűbb az egyes lépéseket a telepítési útmutató alapján manuálisan végezni.\n" - -read -n 1 -p "Folytatja? (i/N)" -s DO -if [ "$DO" != "i" ]; then echo " ok, kiléptem..."; exit 1; fi -echo -e "\n" - -for f in install.d/* -do - echo -e "\n----------------------------------------------\n$f\n----------------------------------------------\n" - ./$f $@ - if [ "$?" == 255 ]; then echo "Fatális hiba! A telepítő kilép."; exit 255; fi; -done - -echo -e "MaYoR (c) setup\n" diff --git a/mayor-mod/bin/backup.sh b/mayor-mod/bin/backup.sh new file mode 100644 index 00000000..152a9b7c --- /dev/null +++ b/mayor-mod/bin/backup.sh @@ -0,0 +1,317 @@ +#!/bin/bash + +OPT_SPEC="hnlf:d::" +LONG_OPT_SPEC="help,now,skip-lock,file:,backup-file:,dir:,backup-dir::" +PARSED_OPTIONS=$(getopt -n "$0" -a -o $OPT_SPEC --long $LONG_OPT_SPEC -- "$@") +OPTIONS_RET=$? +eval set -- "$PARSED_OPTIONS" + +help_usage() { +cat < $LOCKFILE +# echo -n " - Aktív munkamenetek törlése... " ### erre elvileg itt nincs szükség +# $MYSQL $MYSQL_PARAMETERS -e"DELETE FROM mayor_login.session" +# echo "kész." + else + if [ $VERBOSE -gt 1 ]; then echo -e "* A web-es elérés már le van tiltva..."; fi + LOCK_MARAD=1 + fi +else + if [ $VERBOSE -gt 1 ]; then echo -e "* A lock-olást a kérésedre kihagytam..."; fi +fi + +function freeup_lock { +if [ -e $LOCKFILE ]; then + if [ ! -z $LOCKFILE ] && [ $LOCK_MARAD != 1 ]; then + if [ $VERBOSE -gt 1 ]; then echo -e "-"; echo -n "* A web-es hozzáférés engedélyezése:..."; fi + rm $LOCKFILE + if [ $VERBOSE -gt 1 ]; then echo -e "kész."; echo -e "-"; fi + fi +fi +} + + +## +# A könyvtárak létrehozása +## + +if [ ! -e $BACKUPDIR ]; then + mkdir $BACKUPDIR > /dev/null 2>&1 + if [ $? -ne 1 ]; then + echo "*** Nem sikerült a $BACKUPDIR könyvtárat létrehozni!" + echo "**** MaYoR Backup failure! ****" + freeup_lock + exit 1 + fi +fi +chown $WEB_SERVER_USER $BACKUPDIR +chmod 700 $BACKUPDIR + +if [ -e $BACKUPDIR/$BACKUPFILE.tgz ]; then + echo -e "\n**** ERROR: már volt mentés: $BACKUPDIR/$BACKUPFILE.tgz ****\n" + freeup_lock + exit 1 +fi +mkdir $BACKUPDIR/$BACKUPFILE +chown $WEB_SERVER_USER $BACKUPDIR/$BACKUPFILE +chmod 700 $BACKUPDIR/$BACKUPFILE + +## +# mysql adatbázis mentése +## +if [ $VERBOSE -gt 0 ]; then + echo -e "-" + echo -e "* Backup fájl: $BACKUPFILE.tgz" +fi + +if [ "$MYSQL_HOST" == "" ]; then + MYSQL_HOST="localhost" +fi + +DB_INTEZMENYEK='' +if [ -f $MYSQL ] && [ -f $MYSQLDUMP ]; then + + if [ -f "$BASEDIR/config/my.cnf" ]; then + MYSQL_CONFIG="--defaults-extra-file=$BASEDIR/config/my.cnf" ##Vigyázat! a 'mysql' kliens rossz! Néha beleveszi a $(pwd) tartamát is! + TEST=$(echo "SHOW VARIABLES LIKE '%character_set_client%'" | $MYSQL "$MYSQL_CONFIG" | tail -n+2 | cut -f 2) +### Csak character_set_client=utf8 engedélyezett + if [ "$TEST" == "utf8" ]; then + if [ $VERBOSE -gt 2 ]; then echo -e "- MySQL-connect OK (my.cnf)" ; fi + else + MYSQL_CONFIG="-h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW --default-character-set=utf8" + fi + else + MYSQL_CONFIG="-h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW --default-character-set=utf8" + fi + +### Ellenőrizzük + TEST=$(echo "SHOW VARIABLES LIKE '%character_set_client%'" | $MYSQL $MYSQL_CONFIG | tail -n+2 | cut -f 2) + if [ "$TEST" == "utf8" ]; then + if [ $VERBOSE -gt 2 ]; then echo -e "- MySQL-connect OK (utf8+user/passw)"; fi + else + echo -e "*** MySQL-connect ERROR (nem utf8 vagy hibás user/passw)" + exit 2 + fi + + DATABASES='' + for DB in $(echo 'SHOW DATABASES' | $MYSQL $MYSQL_CONFIG); do + if [[ ! $EXCLUDED_DBS =~ .*$DB.* ]] && { [[ $DB =~ ^mayor.* ]] || [[ $DB =~ ^naplo.* ]] || [[ $DB =~ ^intezmeny.* ]]; } then + DATABASES="$DATABASES $DB" + fi + done + DB_INTEZMENYEK=$($MYSQL $MYSQL_CONFIG -e "SET NAMES 'utf8'; SELECT rovidNev FROM mayor_naplo.intezmeny; " | tail -n+2 ) ### Elvileg itt sem lehetne ékezetes + +else + echo -e "*** MySQL ERROR: A mysql kliens nem található: $MYSQL\n" + freeup_lock + exit 2 +fi + + +## +# Adatbázisok mentése +## + +if [ $VERBOSE -gt 2 ]; then echo -e "* Adatbázisok mentése:"; fi + +for DATABASE in $DATABASES; do + if [ ! -z $MYSQLDUMP ]; then + ### SET NAMES-hez: --set-charset + ### Szebb: --result-file=file_name +# mysqldump $MYSQL_CONFIG -R --set-charset --result-file="$BACKUPDIR/$BACKUPFILE/$DATABASE.sql" $DATABASE + $MYSQLDUMP $MYSQL_CONFIG -R --set-charset --result-file="$BACKUPDIR/$BACKUPFILE/$DATABASE.sql" $DATABASE + else + mysqldump $MYSQL_CONFIG -R --set-charset --result-file="$BACKUPDIR/$BACKUPFILE/$DATABASE.sql" $DATABASE + fi + if [ $VERBOSE -gt 3 ]; then echo -e "- $DATABASE"; fi +done + + +## +# A honlap mentése +## +if [ $VERBOSE -gt 2 ]; then echo -e "* Fájlok mentése:"; fi +mkdir $BACKUPDIR/$BACKUPFILE/log +cp -a $BASEDIR/log/revision $BACKUPDIR/$BACKUPFILE/log/revision +if [ $VERBOSE -gt 3 ]; then echo -e "- revision"; fi +cp -a $BASEDIR/www $BACKUPDIR/$BACKUPFILE/www +if [ $VERBOSE -gt 3 ]; then echo -e "- www/*"; fi +cp -a $BASEDIR/config $BACKUPDIR/$BACKUPFILE/config +if [ $VERBOSE -gt 3 ]; then echo -e "- config/*"; fi + +if [ $VERBOSE -gt 2 ]; then echo -e "* Templétek mentése:"; fi +for RN in $(echo $DB_INTEZMENYEK); do ## a nyomtatási templétek is legyenek benne a mentésben +if [ -d "$BASEDIR/print/module-naplo/templates/$RN" ]; then + mkdir -p $BACKUPDIR/$BACKUPFILE/print/module-naplo/templates/ + cp -a $BASEDIR/print/module-naplo/templates/$RN $BACKUPDIR/$BACKUPFILE/print/module-naplo/templates/$RN + if [ $VERBOSE -gt 3 ]; then echo -e "- $RN/*"; fi +fi +done + +if [ "$SAVELDAP" == 1 ]; then + + ## + # Az LDAP adatbázis + ## + if [ $VERBOSE -gt 1 ]; then echo -e "* LDAP mentése"; fi + + /etc/init.d/slapd stop + sleep 1 + + slapcat -b $BASEDN -l $BACKUPDIR/$BACKUPFILE/ldap.ldif + + cp -a $LDAPDBDIR $BACKUPDIR/$BACKUPFILE/ldap + + /etc/init.d/slapd start + + ## + # LDAP konfig file-ok mentése (schema) + ## + + mkdir $BACKUPDIR/$BACKUPFILE/etc + cp -a $LDAPCONFDIR $BACKUPDIR/$BACKUPFILE/etc/ + +fi + +## +# Becsomagolás +## + +if [ $VERBOSE -gt 2 ]; then echo -e "* Becsaomagolás"; fi +cd $BACKUPDIR +#### Ez a korábbi szerintem hibás: +#### tar cfz ${BACKUPFILE}.tgz ${DATE} +#tar cfz ${BACKUPFILE}.tgz ${BACKUPFILE} ##Ez is néha... + +# ez már jó +tar -czf "$BACKUPFILE.tgz" "$BACKUPFILE/" +rm -rf $BACKUPFILE +#Debian6 inkompatibilis: tar cfz ${BACKUPFILE}.tgz --remove-files ${BACKUPFILE} + +if [ $VERBOSE -gt 0 ]; then echo -e "* Takarítás"; fi +## +# Mentés átmásolása másik szerverre +# rsync # Losonci János kiegészítése (losy@agymk.sulinet.hu) +## + +if [ "$RSYNC" == 1 ]; then + if [ $VERBOSE -gt 2 ]; then echo -e "* RSYNC küldés"; fi + RSYNCBIN=$(which rsync) + if [ "$RSYNCBIN" != "" ]; then + echo $RSYNCBIN -auvE $BACKUPDIR/ $RUSER@$RHOST:$RPATH/ + $RSYNCBIN -auvE $BACKUPDIR/ $RUSER@$RHOST:$RPATH/ + if [ $? -ne 0 ]; then + echo "rsync error!" + fi + fi +fi + +## +# Elavult mentés törlése +## + +declare -i BDAYS=BACKUPDAYS +if [ $BDAYS -gt 0 ]; then + find $BACKUPDIR -mtime +$BDAYS -exec rm {} \; +fi + +### +## Végül a lock-olás feloldása +# +freeup_lock +if [ $VERBOSE -gt 1 ]; then echo -e "* Backup-script vége.\n"; fi + +### \ No newline at end of file diff --git a/mayor-mod/bin/crypt-backup.sh b/mayor-mod/bin/crypt-backup.sh new file mode 100644 index 00000000..11e10a27 --- /dev/null +++ b/mayor-mod/bin/crypt-backup.sh @@ -0,0 +1,144 @@ +#!/bin/bash +# +# Example: mayor crypt-backup --backup-file=/tmp/wiki.tgz +# Az eredmény a $BACKUPDIR/$DATE-crypt.tgz állományba kerül +# (Vagy jobb lenne, ha a file nevéből venné a nevét?) +# +# TODO: ellenőrizni kell még, hogy van-e openssl és aespipe +# + +OPT_SPEC="hf:d::" +LONG_OPT_SPEC="help,file:,backup-file:,dir:,backup-dir::" +PARSED_OPTIONS=$(getopt -n "$0" -a -o $OPT_SPEC --long $LONG_OPT_SPEC -- "$@") +OPTIONS_RET=$? +eval set -- "$PARSED_OPTIONS" + +help_usage() { +cat < /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Nem sikerült a ${BACKUPDIR} könyvtárat létrehozni!" + echo "MaYoR Backup failure!" + exit 3 + fi +fi +CRYPTDIR=$BACKUPDIR/$DATE +if [ ! -e $CRYPTDIR ]; then + mkdir $CRYPTDIR +fi +chown $WEB_SERVER_USER $BACKUPDIR +chmod 700 $BACKUPDIR + +if [ ! -f $BACKUPFILE ]; then + # Próbáljuk meg a mai dátum szerinti backup-ot (alapértelmezés) + echo -e " HIBA: Hiányzik a kódolandó mentési állomámny: (${BACKUPFILE})\n" + BACKUPFILE=$BACKUPDIR/${BACKUPFILE} + echo "Próbáljuk a mentéi könyvtáron belül: ${BACKUPFILE}" + if [ ! -f $BACKUPFILE ]; then + echo -e " HIBA: Hiányzik a kódolandó mentési állomámny: (${BACKUPFILE})\n" + BACKUPFILE=$BACKUPDIR/${PREFIX}${DATE}.tgz + echo "Próbáljuk az alapértelmezett állománynevet: ${BACKUPFILE}" + if [ ! -e $BACKUPFILE ]; then + echo -e " HIBA: Hiányzik a kódolandó mentési állomámny: (${BACKUPFILE})\n" + exit 3 + fi + fi +fi +BASENAME=`basename $BACKUPFILE` + +# Publikus kulcs lekérdezése +echo 'SELECT publicKey FROM mayorSsl' | $MYSQL -p$PW -u$USER $DB | grep -v publicKey | sed -e 's/\\n/\n/g' > $CRYPTDIR/id_rsa.pub + +# Véletlen kulcs generálás a szimmetrikus AES kódoláshoz +pwgen -nc 50 1 > $CRYPTDIR/key.txt + +# AES kódolás +aespipe -P $CRYPTDIR/key.txt -e aes256 < $BACKUPFILE > $CRYPTDIR/$BASENAME.aes + +# A kulcsok RSA kódolása a publikus kulccsal +openssl rsautl -encrypt -inkey $CRYPTDIR/id_rsa.pub -pubin -in $CRYPTDIR/key.txt -out $CRYPTDIR/key.rsa + +# Kulcsok törlése +rm $CRYPTDIR/id_rsa.pub +rm $CRYPTDIR/key.txt + +cd $BACKUPDIR +tar cfz ${DATE}-crypt.tgz ${DATE} +rm -rf $DATE + +echo -e "\nBecsomagolva: $BACKUPDIR/${DATE}-crypt.tgz\n\n" diff --git a/mayor-mod/bin/decrypt-backup.sh b/mayor-mod/bin/decrypt-backup.sh new file mode 100644 index 00000000..9eca4375 --- /dev/null +++ b/mayor-mod/bin/decrypt-backup.sh @@ -0,0 +1,138 @@ +#!/bin/bash +# +# Example: mayor decrypt-backup --crypted-file=/home/backup/20110515-crypt.tgz +# Az eredmény a $BACKUPDIR alá kerül az eredetileg elkódolt állomány nevéből +# származtatott néven: file.kit --> file-decrypt.kit +# +# TODO: ellenőrizni kell még az openssl és az aespipe meglétét +# + +OPT_SPEC="hf:d::" +LONG_OPT_SPEC="help,file:,crypted-file:,dir:,backup-dir::" +PARSED_OPTIONS=$(getopt -n "$0" -a -o $OPT_SPEC --long $LONG_OPT_SPEC -- "$@") +OPTIONS_RET=$? +eval set -- "$PARSED_OPTIONS" + +help_usage() { +cat < /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Nem sikerült a ${BACKUPDIR} könyvtárat létrehozni!" + echo "MaYoR Backup failure!" + exit 3 + fi +fi +chown $WEB_SERVER_USER $BACKUPDIR +chmod 700 $BACKUPDIR + +# bejövő paraméterek feldolgozása (crypted-file) +if [ ! -f $FILE ]; then + echo -e " HIBA: Hiányzik a dekódolandó mentési állomámny: ${FILE}\n" + FILE=$BACKUPDIR/${FILE} + echo "Próbáljuk a mentési könyvtárban (${FILE})" + if [ ! -f $FILE ]; then + echo -e " HIBA: Hiányzik a dekódolandó mentési állomámny: ${FILE}\n" + FILE=$BACKUPDIR/${PREFIX}${DATE}-crypt.tgz + echo "Próbáljuk az alapértelmezett állományt (${FILE})" + if [ ! -e $FILE ]; then + echo " HIBA: Hiányzik a dekódolandó mentési állomámny: ${FILE}" + exit 4 + fi + fi +fi +BASENAME=`basename $FILE` + +cd $BACKUPDIR +tar xfz $FILE +TARFILES=`tar tf $FILE` +SUBDIR=`for f in $TARFILES; do echo $f; break; done` +AESFILE=`echo $TARFILES | sed -e 's/ /\n/g' | grep '.aes'` +AESBASE=`basename $AESFILE | sed -e 's/.aes//g'` +DECRYPTFILE=`echo $AESBASE | sed -e 's/\.\([a-z]*\)$/-decrypt\.\1/'` + +# A privát kulcs lekérdezése +echo 'SELECT privateKey FROM mayorSsl' | $MYSQL -p$PW -u$USER $DB | grep -v privateKey | sed -e 's/\\n/\n/g' > $BACKUPDIR/$SUBDIR/id_rsa + +# AES kulcs dekódolása +openssl rsautl -decrypt -inkey $BACKUPDIR/$SUBDIR/id_rsa -in $BACKUPDIR/$SUBDIR/key.rsa -out $BACKUPDIR/$SUBDIR/key.txt + +# AES dekódolás (feltételezzük, hogy az eredmény tgz +aespipe -P $BACKUPDIR/$SUBDIR/key.txt -d -e aes256 < $BACKUPDIR/$AESFILE > $BACKUPDIR/$DECRYPTFILE + +# Törlés +rm -rf $BACKUPDIR/$SUBDIR + +echo -e "\nKicsomagolva: $BACKUPDIR/$DECRYPTFILE\n\n" diff --git a/mayor-mod/bin/etc/cron.daily/mayor b/mayor-mod/bin/etc/cron.daily/mayor new file mode 100755 index 00000000..815cc023 --- /dev/null +++ b/mayor-mod/bin/etc/cron.daily/mayor @@ -0,0 +1,13 @@ +#!/bin/bash + +# A helyes környezet beállítása (svn alapú frissítés esetén az ékezetes file-nevekhez) +export LANG=hu_HU.UTF-8 + +# Napló napi mentése +/usr/local/sbin/mayor backup + +# Heti frissítés +if [ `date +'%w'` == 0 ]; then + /usr/local/sbin/mayor update +fi + diff --git a/mayor-mod/bin/help.sh b/mayor-mod/bin/help.sh new file mode 100644 index 00000000..e983ccd3 --- /dev/null +++ b/mayor-mod/bin/help.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +OPT_SPEC="hf::" +LONG_OPT_SPEC="help,file:,f::" +PARSED_OPTIONS=$(getopt -n "$0" -a -o $OPT_SPEC --long $LONG_OPT_SPEC -- "$@") +OPTIONS_RET=$? +eval set -- "$PARSED_OPTIONS" + +help_usage() { + print_help; + echo -e "\nHELP használata: mayor help [parancs]\n\n" +} + +if [ $OPTIONS_RET -ne 0 ] || [ $# -le 1 ]; then help_usage; exit; fi + +while [ $# -ge 1 ]; do + case $1 in + --help | -h ) help_usage + exit + ;; + + --file | -f ) shift + FILE="$1" + echo "FILE: $FILE" + ;; + + -- ) shift + break + ;; + + * ) echo "HIBA: ismeretlen opció: $1" # ide elvileg sose jutunk, mert a getopts már kiszűrte a hibás paramétereket... + exit + ;; + esac + shift +done + +while [ $# -ge 1 ]; do + echo -e "\n---------- HELP: $1 ----------\n" + if [[ ! "${CMDS[*]}" =~ .*$1.* ]]; then + echo -e "Ismeretlen parancs: $1" + #print_help + else + . ./$1.sh --help + fi + shift +done diff --git a/mayor-mod/bin/lock.sh b/mayor-mod/bin/lock.sh new file mode 100644 index 00000000..ca275705 --- /dev/null +++ b/mayor-mod/bin/lock.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +help_usage() { +cat < $LOCKFILE + if [ $VERBOSE -gt 0 ]; then echo -e "kész.\n"; fi +fi + diff --git a/mayor-mod/bin/mayor b/mayor-mod/bin/mayor new file mode 100755 index 00000000..09168cc0 --- /dev/null +++ b/mayor-mod/bin/mayor @@ -0,0 +1,74 @@ +#!/bin/bash + +VERSION="2.0" +echo -e "\nmayor szkript - verzió: $VERSION (" $(date '+%Y-%m-%d') ")" + +CMDS=(backup update lock unlock crypt-backup decrypt-backup remote-backup restore help) +MODS=(mayor-base mayor-portal mayor-naplo mayor-naplo-sni mayor-wiki mayor-felveteli mayor-installer mayor-installer-sulix mayor-jatek mayor-locales-de_DE mayor-locales-en_US mayor-local-jp_JP) +DESC=('a rendszer mentése' 'a rendszer frissítése' 'a rendszer zárolása (lockfile)' 'a rendszer feloldása' 'a mentés titkosítása (ß)' 'a titkosított mentés visszakódolása (ß)' 'mentés a központi (távoli) szerverre' 'mentés visszatöltése' 'A parancs működésének leírása') +#OPTS=('--skip-lock') +#OPTDESC=('a rendszer zárolásának kihagyása') +DATE=$(date "+%Y%m%d") +DATETIME=$(date "+%Y-%m-%d %H:%M:%S") + +print_help() { + echo -e "\nHasználat: mayor [parancs] [opciók]\n\nParancs" + for ((i=0; i<${#CMDS[@]}; i=i+1)); do + len=$(echo ${CMDS[$i]} | wc -m) + if [ "$len" -lt 13 ]; then + echo -e " - ${CMDS[$i]}:\t\t${DESC[$i]}" + else + echo -e " - ${CMDS[$i]}:\t${DESC[$i]}" + fi + done +# echo -e "\nOpciók" +# for ((i=0; i<${#OPTS[@]}; i=i+1)); do +# echo " ${OPTS[$i]}: ${OPTDESC[$i]}" +# done + echo "" +} + +# Ellenőrizzük, hogy van-e configurációs állomány +if [ -f /etc/mayor/main.conf ]; then + . /etc/mayor/main.conf +else + echo -e "\n*** HIBA: hiányzó konfigurációs file: /etc/mayor/main.conf\n" + exit 1 +fi + +# Ha nincs paraméter, akkor írjuk ki a tennivalót +if [ -z $1 ]; then + print_help + exit 1 +fi + +# A paraméter ellenőrzése +for ((i=0; i<${#CMDS[@]}; i=i+1)); do + if [ ${CMDS[$i]} == "$1" ]; then + CMD=${CMDS[$i]} + break + fi +done + +if [ -z $CMD ]; then + echo -e "\n(>>> HIBA: ismeretlen parancs: $1)\n" + print_help + exit 1 +else + echo -e "(>>> $CMD)\n" +fi + +# Alapértelmezés +if [ "$MYSQL_HOST" == "" ]; then + MYSQL_HOST="localhost" +fi + +shift +# A parancs végrehajtása +cd $BASEDIR/bin +if [ -z $UPDATELOG ]; then + . ./$CMD.sh +else + . ./$CMD.sh 2>&1 | tee -a $UPDATELOG +fi + diff --git a/mayor-mod/bin/remote-backup.sh b/mayor-mod/bin/remote-backup.sh new file mode 100644 index 00000000..71e241d5 --- /dev/null +++ b/mayor-mod/bin/remote-backup.sh @@ -0,0 +1,170 @@ +#!/bin/bash +# +# Example: mayor remote-backup --backup-file=/tmp/wiki.tgz +# Az eredmény a $BACKUPDIR/$DATE-crypt.tgz állományba kerül +# (Vagy jobb lenne, ha a file nevéből venné a nevét?) +# +# TODO: ellenőrizni kell még, hogy van-e openssl és aespipe +# + +OPT_SPEC="hf:d::" +LONG_OPT_SPEC="help,file:,backup-file:,dir:,backup-dir::" +PARSED_OPTIONS=$(getopt -n "$0" -a -o $OPT_SPEC --long $LONG_OPT_SPEC -- "$@") +OPTIONS_RET=$? +eval set -- "$PARSED_OPTIONS" + +help_usage() { +cat < /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Nem sikerült a ${BACKUPDIR} könyvtárat létrehozni!" + echo "MaYoR Backup failure!" + exit 3 + fi +fi +CRYPTDIR=$BACKUPDIR/$DATE +if [ ! -e $CRYPTDIR ]; then + mkdir $CRYPTDIR +fi +chown $WEB_SERVER_USER $BACKUPDIR +chmod 700 $BACKUPDIR + +if [ ! -f $FILE ]; then + echo -e " HIBA: Hiányzik a kódolandó mentési állomámny: ${FILE}" + FILE=$BACKUPDIR/${FILE} + echo "Próbáljuk a mentési könyvtárban! (${FILE})" + if [ ! -f $FILE ]; then + echo -e " HIBA: Hiányzik a kódolandó mentési állomámny: ${FILE}" + FILE=$BACKUPDIR/${PREFIX}${DATE}.tgz + echo "Próbáljuk az alapértelmezett állományt! (${FILE})" + if [ ! -e $FILE ]; then + echo -e " HIBA: Hiányzik a kódolandó mentési állomámny: ${FILE}" + exit 3 + fi + fi +fi +BASENAME=`basename $FILE` + +# Publikus kulcs lekérdezése +echo 'SELECT publicKey FROM mayorSsl' | $MYSQL -p$PW -u$USER $DB | grep -v publicKey | sed -e 's/\\n/\n/g' > $CRYPTDIR/id_rsa.pub + +# Véletlen kulcs generálás a szimmetrikus AES kódoláshoz +pwgen -nc 50 1 > $CRYPTDIR/key.txt + +# AES kódolás +aespipe -P $CRYPTDIR/key.txt -e aes256 < $FILE > $CRYPTDIR/$BASENAME.aes + +# A kulcsok RSA kódolása a publikus kulccsal +openssl rsautl -encrypt -inkey $CRYPTDIR/id_rsa.pub -pubin -in $CRYPTDIR/key.txt -out $CRYPTDIR/key.rsa + +# Kulcsok törlése +rm $CRYPTDIR/id_rsa.pub +rm $CRYPTDIR/key.txt + +cd $BACKUPDIR +tar cfz ${DATE}-crypt.tgz ${DATE} +rm -rf $DATE + +echo -e "\nBecsomagolva: $BACKUPDIR/${DATE}-crypt.tgz\n\n" + +# A privát kulcs lekérdezése, elhelyezése +if [ ! -d $BASEDIR/ssh ]; then + echo "Létrehozzuk a $BASEDIR/ssh könyvtárat, amibe belerakjuk a privát kulcsot..." + mkdir $BASEDIR/ssh + chmod 700 $BASEDIR/ssh +fi +if [ ! -f $BASEDIR/ssh/id_rsa ]; then + echo 'SELECT privateKey FROM mayorSsl' | $MYSQL -p$PW -u$USER $DB | grep -v privateKey | sed -e 's/\\n/\n/g' > $BASEDIR/ssh/id_rsa + chmod 700 $BASEDIR/ssh/id_rsa +fi + +# Az intézmény OM kódjának lekérdezése + +# A mayor_naplo adatbázis eléréséhez szükséges paraméterek lekérdezése a konfig-ból... +DB=`grep db $BASEDIR/config/module-naplo/config.php | sed -e "s/$.*=\ *['|\"]//g" -e "s/['|\"];//g"` +USER=`grep userRead $BASEDIR/config/module-naplo/config.php | sed -e "s/$.*=\ *['|\"]//g" -e "s/['|\"];//g" | sed 's/^ *//g'` +PW=`grep pwRead $BASEDIR/config/module-naplo/config.php | sed -e "s/$.*=\ *['|\"]//g" -e "s/['|\"];//g" | sed 's/^ *//g'` + +OMKOD=`echo 'SELECT SUBSTR(OMKod,-6) FROM intezmeny WHERE alapertelmezett = 1' | $MYSQL -p$PW -u$USER $DB | grep -v OMKod` +SSH_USER="om$OMKOD" +echo $SSH_USER + +# A kódolt adatállomány másolása +scp -i $BASEDIR/ssh/id_rsa -P $SSH_PORT $BACKUPDIR/${DATE}-crypt.tgz $SSH_USER@$SSH_HOST:/home/$SSH_USER/ diff --git a/mayor-mod/bin/restore.sh b/mayor-mod/bin/restore.sh new file mode 100644 index 00000000..7a1195ed --- /dev/null +++ b/mayor-mod/bin/restore.sh @@ -0,0 +1,257 @@ +#!/bin/bash + +OPT_SPEC="hkprf:d:t::" +LONG_OPT_SPEC="help,keep-old-passwords,restore-parent,restore-private,tmp-dir:,file:,backup-file:,dir:,base-dir::" +PARSED_OPTIONS=$(getopt -n "$0" -a -o $OPT_SPEC --long $LONG_OPT_SPEC -- "$@") +OPTIONS_RET=$? +eval set -- "$PARSED_OPTIONS" + +help_usage() { +cat </dev/null; then + echo "ok." + else + echo "hiba." + exit 3 + fi +fi + +if [ ! -d "${RTMPDIR}/restore" ]; then + if ! mkdir "${RTMPDIR}/restore" 2>/dev/null; then + echo "Hiba: Az ideiglenes könyvtár nem írható (${RTMPDIR})!" + exit 4 + fi +fi +chmod 700 "${RTMPDIR}/restore" +cd "${RTMPDIR}/restore" +tar xvfz $RBACKUPFILE +DT=$(ls) +echo "A mentés dátuma: ${DT}" +cd ${DT} + +RREVISIONFILE="${RTMPDIR}/restore/${DT}/log/revision" +declare -i BAK_REV +if [ ! -e "${RREVISIONFILE}" ]; then + echo "Hiba: A mentési állomány nem tartalmaz verzió információt!" + echo -e " A mentési állományon belül, a ${DT}/log/revision állományba írja be a revision számot (pl: 2512)!\n" + cleartmp + exit 5 +fi +BAK_REV=$(cat $RREVISIONFILE) +echo "A mentett rendszer revision száma: ${BAK_REV}" + +if [ ${BAK_REV} -gt ${INST_REV} ]; then + echo "Hiba: A mentett rendszer újabb, mint a telepített!" + echo -e " A telepített rendszer revision száma nagyobb vagy egyenlő kell legyen a mentett rendszer revision számánál!\n Telepítsen frissíebb rendszert!\n" + cleartmp + exit 6 +fi + +# A telepített rendszer beállításainsak betöltése +if [ -f "${RBASEDIR}/config/main.conf" ]; then + . "${RBASEDIR}/config/main.conf" +else + echo "Hiba: A telepített rendszer nincs beállítva!" + echo -e " Hiányzik a konfigurációs állomány: ${RBASEDIR}/config/main.conf\n" + cleartmp + exit 7 +fi + +# Az adatbázisok betöltése +NAPLOUSER=$(egrep 'userWrite.*=' $BASEDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +NAPLOUSERREAD=$(egrep 'userRead.*=' $BASEDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") +DBS=$($MYSQL -h$MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PW -e"SHOW DATABASES") +if [ "$RESTORE_PARENT" == "1" ]; then + FILES="mayor_naplo.sql mayor_parent.sql intezmeny_*.sql naplo_*.sql" +else + FILES="mayor_naplo.sql intezmeny_*.sql naplo_*.sql" +fi +if [ "$RESTORE_PRIVATE" == "1" ]; then + FILES="$FILES mayor_private.sql" +fi +for SQLFILE in $FILES; do + if [ -e "${SQLFILE}" ]; then + DB=${SQLFILE%.sql} + echo -n "${DB} ... " + if [[ ! ${DBS} =~ .*$DB.* ]]; then + echo -n "... " + (cat < ${iNCDIR}/config.php.backup" + mv "${iNCDIR}/config.php" "${iNCDIR}/config.php.backup" + fi +fi + +cat "${bNCDIR}/config.php" | sed \ + -e "s/db\(.*\)$bDB\(.*\)/db\1$iDB\2/g" \ + -e "s/userWrite\(.*\)$bUSER\(.*\)/userWrite\1$iUSER\2/g" \ + -e "s/userRead\(.*\)$bUSERREAD\(.*\)/userRead\1$iUSERREAD\2/g" \ + -e "s/$bPW/$iPW/g" -e "s/$bPWREAD/$iPWREAD/g" > "${iNCDIR}/config.php" + +for FILE in config-*.php; do + echo -n "$FILE ... " + # mentés + if [ -e "${iNCDIR}/$FILE" ]; then + if [ ! -e "${iNCDIR}/$FILE.backup" ]; then + echo -n "... " + mv "${iNCDIR}/$FILE" "${iNCDIR}/$FILE.backup" + fi + fi + cp $FILE "${iNCDIR}/$FILE" + echo ok +done + +cd ${BASEDIR}/bin +if [ -z $UPDATELOG ]; then + . update.sh -e -r$BAK_REV -b${BASEDIR} +else + . update.sh -e -r$BAK_REV -b${BASEDIR} 2>&1 | tee -a $UPDATELOG +fi + +# Az ideiglenes könyvtár törlése +cleartmp + diff --git a/mayor-mod/bin/sbin/eNaploBackup.sh b/mayor-mod/bin/sbin/eNaploBackup.sh new file mode 100755 index 00000000..5bdba177 --- /dev/null +++ b/mayor-mod/bin/sbin/eNaploBackup.sh @@ -0,0 +1,95 @@ +#!/bin/sh +## +# Az elektronikus mentése (Version 1.0) +## + + DATE=`date +%Y%m%d` + NAPLO_BACKUP_BASE_DIR='/backup/naplo' + NAPLO_BACKUP_DIR="$NAPLO_BACKUP_BASE_DIR/$DATE" + + DATABASES='mayor_parent mayor_private mayor_naplo intezmeny_fasori naplo_fasori_2007' + #MYSQL_DB='%MYSQL_NAPLO_DB%' + MYSQL_USER='%MYSQL_NAPLO_USER%' + MYSQL_PW='%MYSQL_NAPLO_PW%' + + WWW_SSL_DIR='%BASEDIR%' + WEB_SERVER_USER='%WEB_SERVER_USER%' + EXPIRE_DATE=`date -d '30 days ago' +%Y%m%d` + + BASEDN='%BASEDN%' + LDAP_CONF_DIR='%LDAP_CONF_DIR%' + LDAP_DB_DIR='%LDAP_DB_DIR%' + +## +# A könyvtárak létrehozása +## + if [ ! -e $NAPLO_BACKUP_BASE_DIR ]; then + /bin/mkdir $NAPLO_BACKUP_BASE_DIR + fi + /bin/chown $WEB_SERVER_USER $NAPLO_BACKUP_BASE_DIR + /bin/chmod 700 $NAPLO_BACKUP_BASE_DIR + + if [ -e $NAPLO_BACKUP_DIR.tgz ]; then + exit 1 + fi + /bin/mkdir $NAPLO_BACKUP_DIR + /bin/chown $WEB_SERVER_USER $NAPLO_BACKUP_DIR + /bin/chmod 700 $NAPLO_BACKUP_DIR + +## +# mysql adatbázis mentése +## + +for DATABASE in $DATABASES; do + /usr/bin/mysqldump -p$MYSQL_PW -u$MYSQL_USER $DATABASE >> $NAPLO_BACKUP_DIR/$DATABASE.sql +done + +## +# mysql adatbázis mentése +## + +# /usr/bin/mysqldump -p$MYSQL_PW -u$MYSQL_USER $MYSQL_DB >> $NAPLO_BACKUP_DIR/$MYSQL_DB.sql + +## +# A honlap mentése +## + + mkdir $NAPLO_BACKUP_DIR/html + + /bin/cp -a $WWW_SSL_DIR/* $NAPLO_BACKUP_DIR/html/ + +## +# Az LDAP adatbázis +## + + /etc/init.d/slapd stop + /bin/sleep 1 + + /usr/sbin/slapcat -b $BASEDN -l $NAPLO_BACKUP_DIR/ldap.ldif + + /bin/cp -a $LDAP_DB_DIR $NAPLO_BACKUP_DIR/ldap + + /etc/init.d/slapd start + +## +# LDAP konfig file-ok mentése (schema) +## + + /bin/mkdir $NAPLO_BACKUP_DIR/etc + /bin/cp -a $LDAP_CONF_DIR $NAPLO_BACKUP_DIR/etc/ + +## +# Becsomagolás +## + + cd $NAPLO_BACKUP_BASE_DIR + /bin/tar cfz $DATE.tgz $DATE + /bin/rm -rf $NAPLO_BACKUP_DIR + +## +# Elavult mentés tölése +## + + if [ -e $NAPLO_BACKUP_BASE_DIR/$EXPIRE_DATE.tgz ]; then + rm -rf $NAPLO_BACKUP_BASE_DIR/$EXPIRE_DATE.tgz + fi diff --git a/mayor-mod/bin/sbin/eNaploRestore.sh b/mayor-mod/bin/sbin/eNaploRestore.sh new file mode 100755 index 00000000..f383360f --- /dev/null +++ b/mayor-mod/bin/sbin/eNaploRestore.sh @@ -0,0 +1,82 @@ +#!/bin/sh +## +# Az elektronikus visszatöltése (Version 1.0) +## + + NAPLO_BACKUP_BASE_DIR='/backup/naplo' + NAPLO_BACKUP_TMP_DIR="$NAPLO_BACKUP_BASE_DIR/tmp" + + DATABASE='%MYSQL_NAPLO_DB%' + MYSQL_PW='%MYSQL_ROOT_PW%' + MYSQL_USER='root' + + WWW_DIR='%BASEDIR%' + WEB_SERVER_USER='%WEB_SERVER_USER%' + BASEDN='%BASEDN%' + DUMP_FILE="$DATABASE.sql" + LDIF_FILE='ldap.ldif' + LDAP_DB_DIR='%LDAP_DB_DIR%/mayor' + +## +# A paraméter ellenőrzése +## + + if [ -z $1 ]; then + exit 1 + else + if [ -e $NAPLO_BACKUP_BASE_DIR/$1 ]; then + FILE=$1 + DATE=`echo $FILE | cut -d . -f 1` + else + exit 2 + fi + fi + +echo "PARAMÉTER: $1" + +## +# TMP Könyvtár ellenőrzése, létrehozása +## + + if [ ! -e $NAPLO_BACKUP_TMP_DIR ]; then + /bin/mkdir $NAPLO_BACKUP_TMP_DIR + fi + /bin/chown $WEB_SERVER_USER $NAPLO_BACKUP_TMP_DIR + /bin/chmod 700 $NAPLO_BACKUP_TMP_DIR + +## +# Adatfile kicsomagolása +## + + cd $NAPLO_BACKUP_TMP_DIR + /bin/tar xfz $NAPLO_BACKUP_BASE_DIR/$FILE + if [ ! -e $NAPLO_BACKUP_TMP_DIR/$DATE/$DUMP_FILE ]; then + exit 3 + fi + if [ ! -e $NAPLO_BACKUP_TMP_DIR/$DATE/$LDIF_FILE ]; then + exit 4 + fi + +## +# Az LDAP adatbázis visszatöltése/felülírása +## + + /etc/init.d/slapd stop + /bin/sleep 1 + + /bin/rm -rf $LDAP_DB_DIR/* + /usr/sbin/slapadd -c -b $BASEDN -l $NAPLO_BACKUP_TMP_DIR/$DATE/$LDIF_FILE + + /etc/init.d/slapd start + +## +# mysql adatbázis visszatöltése +## + +(cat < $REV + +for f in $PARENT; do + ln -s $DIR/www/policy/private/naplo/$f-pre.php $DIR/www/policy/parent/naplo/$f-pre.php + ln -s $DIR/www/policy/private/naplo/$f.php $DIR/www/policy/parent/naplo/$f.php +done + +for f in $PUBLIC; do + ln -s $DIR/www/policy/private/naplo/$f-pre.php $DIR/www/policy/public/naplo/$f-pre.php + ln -s $DIR/www/policy/private/naplo/$f.php $DIR/www/policy/public/naplo/$f.php +done + +for f in $WRITABLE; do + chmod a+rwx $DIR/$f +done diff --git a/mayor-mod/bin/tex2pdf.sh b/mayor-mod/bin/tex2pdf.sh new file mode 100644 index 00000000..ee177b11 --- /dev/null +++ b/mayor-mod/bin/tex2pdf.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# +# A script segítségével tesztelhetjük, hogy mi történik, mikor a program a haladásinaplót, illetve osztályozónaplót generálja... +# +# Paraméter: a feldolgozandó UTF-8 kódolású TeX állomány "-u8.tex" végződés nélküli neve. +# + +. /etc/mayor/main.conf + +HOME="/tmp" +export HOME + +# Make sure this exists +# cd $BASEDIR/print/module-naplo/tex/ +# fmtutil-sys --cnffile $BASEDIR/print/module-naplo/tex/mayor.cnf --fmtdir $BASEDIR/print/module-naplo/ --byfmt mayor + +cat $1-u8.tex | recode u8..T1 > $1.tex + +tex -fmt $BASEDIR/print/module-naplo/tex/mayor $1.tex + +dvips $1.dvi + +ps2pdf -sPAPERSIZE=a4 -dAutoRotatePages=/None $1.ps + diff --git a/mayor-mod/bin/unlock.sh b/mayor-mod/bin/unlock.sh new file mode 100644 index 00000000..98783f4b --- /dev/null +++ b/mayor-mod/bin/unlock.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +help_usage() { +cat < /dev/null + for MODULE in $MODULES; do + echo -n " $MODULE... " + chmod +x $BASEDIR/bin/mayor + if [ $? != 0 ]; then exit 2; fi + UJ_REV=$($SVN --force export https://svn.mayor.hu/svn/trunk/$MODULE/update "$BASEDIR/update" | grep revision | cut -d ' ' -f 3 | uniq | sed -e 's/\.//g') + if [ $? != 0 ]; then exit 3; fi + echo "kész." + done + else + echo -e "\n\nERROR: A subversion kliens nem található: $SVN" + exit 4 + fi + else + # Munkakönyvtár létrehozása + if [ ! -d $TMPDIR ]; then + mkdir $TMPDIR + chown -R 0:0 $TMPDIR + chmod -R 700 $TMPDIR + else + rm -rf $TMPDIR/* + fi + cd $TMPDIR + # Az md5sum állomány leszedáse + if [ -z $VERSION ]; then + wget "http://www.mayor.hu/download/md5sum" + else + wget "http://www.mayor.hu/download/$VERSION/md5sum" + if [[ ! $HTTP_SERVER =~ .*$VERSION.* ]]; then HTTP_SERVER="$HTTP_SERVER/$VERSION"; fi + fi + if [ $? != 0 ]; then exit 5; fi + UJ_REV=$(grep Revision md5sum | cut -d ' ' -f 2) + if [ "$REV" -lt "$UJ_REV" ]; then + # csomagok leszedése + for MODULE in $MODULES; do + echo -n " $MODULE... " + MOD=$(echo $MODULE | sed "s#/#-#") + FILE=$(grep "$MOD-rev" md5sum | cut -d ' ' -f 3) + if [ "$FILE" != '' ]; then + wget "$HTTP_SERVER/$FILE" + if [ $? != 0 ]; then + echo -e "\n\n ERROR: Az frissítés nem tölthető le: $FILE!\n" + exit 6 + fi + grep $FILE md5sum | md5sum -c --status + if [ $? == 0 ]; then + tar xfz $FILE -C $BASEDIR ./update + else + echo -e "\n\n ERROR: Az ellenörző összeg nem egyezik!\n" + exit 7 + fi + else + echo 'Nincs ilyen modul!' + exit 8 # nem szabad hiányzó csomagok mellett frissíteni!! + fi + done + fi + cd $BASEDIR/bin + fi + fi +else # exec-only + if [ -f $REVISION_FILE ]; then + UJ_REV=$(cat $REVISION_FILE) + else + UJ_REV=0 # nem frissítünk semmit + fi +fi + +if [ "$REV" -ge "$UJ_REV" ]; then + echo -e "\nNincs újabb változat.\n" + echo -e "\n * A szükséges jogosultságok beállítása:" + chmod +x $BASEDIR/bin/mayor + echo 'kész.' +else + echo 'kész.' + . $BASEDIR/update/processUpdateScripts.sh +fi + +PWDTEX=$(pwd) +echo -e "\nMaYoR TeX formátum állomány újragenerálása... " +cd $BASEDIR/print/module-naplo/tex/ && fmtutil-sys --cnffile $BASEDIR/print/module-naplo/tex/mayor.cnf --fmtdir $BASEDIR/print/module-naplo/ --byfmt mayor > /dev/null 2>&1 +echo -e "\nMaYoR XeTeX formátum állomány újragenerálása... " +cd $BASEDIR/print/module-naplo/xetex/ && fmtutil-sys --cnffile $BASEDIR/print/module-naplo/xetex/mayor-xetex.cnf --fmtdir $BASEDIR/print/module-naplo/ --byfmt mayor-xetex > /dev/null 2>&1 +cd $PWDTEX +echo 'kész.' + +echo -e "\nFrissítés vége.\n" +exit 0 diff --git a/mayor-mod/bin/xetex2pdf.sh b/mayor-mod/bin/xetex2pdf.sh new file mode 100644 index 00000000..a4f7bf3f --- /dev/null +++ b/mayor-mod/bin/xetex2pdf.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# A script segítségével tesztelhetjük, hogy mi történik, mikor a program a haladásinaplót, illetve osztályozónaplót generálja +# __NYOMTATAS_XETEX===true beállítás mellett +# +# Paraméter: a feldolgozandó UTF-8 kódolású TeX állomány "-u8.tex" végződés nélküli neve. +# + +. /etc/mayor/main.conf + +HOME="/tmp" +export HOME + +# Make sure this exists +# cd $BASEDIR/print/module-naplo/tex/ +# fmtutil-sys --cnffile $BASEDIR/print/module-naplo/tex/mayor.cnf --fmtdir $BASEDIR/print/module-naplo/ --byfmt mayor + +cat < $1.tex +%\font\kicsi=ecrm0500 +%\font\nagy=ecbx1200 +%\font\vastag=ecsx0800 +%\font\nagyss=ecsx1200 +%\font\normal=ecss0800 +%\font\dolt=ecsi0800 + +\font\kicsi="Linux Libertine O" at 5pt +\font\nagy="Linux Libertine O/B" at 12pt +\font\nagyss="Arial/B" at 12pt +\font\normal="Linux Biolinum O" at 8pt +\font\dolt="Linux Biolinum O/I" at 8pt +\normal + +EOF +cat $1-u8.tex >> $1.tex +xetex -fmt $BASEDIR/print/module-naplo/xetex/mayor-xetex $1.tex + diff --git a/mayor-mod/update/processUpdateScripts.sh b/mayor-mod/update/processUpdateScripts.sh new file mode 100644 index 00000000..61ab5618 --- /dev/null +++ b/mayor-mod/update/processUpdateScripts.sh @@ -0,0 +1,267 @@ +#!/bin/bash + +source $BASEDIR/update/linkme.sh + +# Setting Mysql Connection Parameters +echo -e "[mysqld] +character-set-server = utf8 +collation-server = utf8_hungarian_ci +[client] +default-character-set=utf8 +host=$MYSQL_HOST +user=$MYSQL_USER +password=$MYSQL_PW +" > $BASEDIR/config/my.cnf + +PRECHARSET="SET NAMES 'utf8' COLLATE 'utf8_hungarian_ci'; " ## fontos, hogy a ";" ott legyen a végén!! +#PRECHARSET="$PRECHARSET SET collation_connection = utf8_hungarian_ci; " ## ha a mysql server esetleg régebbi lenne. + +MYSQL_CONFIG="--defaults-extra-file=$BASEDIR/config/my.cnf" +MYSQL_PARAMETERS="" +TEST=$($MYSQL -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW -e exit 2>&1 >/dev/null) +if [ $? == "0" ]; then + echo "SQL-connect test #2 OK" + MYSQL_PARAMETERS="-h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW" +else + echo "Hibás SQL csatlakozás(2)" +fi +TEST=$($MYSQL $MYSQL_CONFIG -e exit 2>&1 >/dev/null) +if [ $? == "0" ]; then + echo "SQL-connect test #1 OK" + MYSQL_PARAMETERS=$MYSQL_CONFIG +else + echo "Hibás SQL csatlakozás(1)" +fi +echo "Karakterkódolás ellenőrzése" +echo "SHOW VARIABLES LIKE 'character%';" | $MYSQL $MYSQL_PARAMETERS +# patch by Acsai Gabor - FreeBSD +# Kiegészítve: Miklós Gergő - Baár-Madas +# gondolatmenet: +# A "default-character-set" beállítása után a "character_set_client" változóból 1db kell legyen, és értéke pontosan "utf8" kell legyen! +### TEST=`echo "SHOW VARIABLES LIKE 'character_set_client'" | $MYSQL $MYSQL_PARAMETERS | grep utf8 | wc -l | tr -d " "` +TEST=$(echo "SHOW VARIABLES LIKE '%character_set_client%'" | $MYSQL $MYSQL_PARAMETERS | tail -n+2 | cut -f 2) +if [ "$TEST" == "utf8" ]; then + echo "SQL-UTF8 test OK" +else + echo -e "\n\nERROR: Hibás - nem utf8 - MySQL kliens karakterkódolás!\n" + echo -e "Ellenőrizd a beállításokat és kérj segítséget a support@mayor.hu -n!\n" + exit 12 +fi +# -- + +run_script() { + FILEELEJE=$(echo $FILE | cut -f 1 -d '-') + FILEREV=${FILEELEJE: -6} + LOGSQL="" + if [ "$FILEREV" != "" ]; then + if [ "$FILEREV" -gt 3399 ]; then + LOGSQL="INSERT IGNORE mayorUpdateLog (scriptFile) VALUES ('${FILE}')" + fi + fi + if [ ! "${FILEREV}" \< "${REVSTR}" ]; then + FILEEXT=$(echo $FILE | cut -f 2 -d '.') + if [ "$FILEEXT" == "sh" ]; then + echo " - Szkript futtatása ($FILE)..." + . $FILE + if [ $? != 0 ]; then exit 13; fi + elif [ "$FILEEXT" == "sql" ]; then + echo " - SQL utasítások végrehajtása ($FILE)..." + FILEDB=$(echo $FILE | cut -f 1 -d '.' | cut -f 3 -d '-') + case "$FILEDB" in + naplo) + DBS=$DB_NAPLO + ;; + intezmeny) + DBS=$DB_INTEZMENY + ;; + auth) + DBS=$DB_AUTH + ;; + *) + DBS=$FILEDB + ;; + esac + for DB in $DBS; do + echo -e "\n $DB..." + + if [ "$FILEREV" != "" ]; then + if [ "$FILEREV" -gt 3399 ]; then + TEST=$((echo $PRECHARSET && echo "SELECT count(*) as db FROM information_schema.TABLES WHERE TABLE_SCHEMA='${DB}' and TABLE_NAME='mayorUpdateLog'") | $MYSQL $MYSQL_PARAMETERS $DB | grep -v "db") + if [ "$TEST" == "0" ]; then + echo " Hiányzik a mayorUpdateLog tábla... tovább..." + continue + fi + fi + fi + + case "$FILEDB" in + naplo) + INTEZMENYDB=$(echo $DB | sed -e 's/\(naplo_\)\(.*\)\(_.*\)/intezmeny_\2/') + INTEZMENYROVIDNEV=$(echo $DB | cut -f 2 -d '_') + TANEV=$(echo $DB | cut -f 3 -d '_') + (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENYDB%/$INTEZMENYDB/g" | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | \ + sed -e "s/%TANEV%/$TANEV/g" | $MYSQL $MYSQL_PARAMETERS $DB + ;; + auth) + (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%MYSQL_ENCODE_STR%/$MYSQL_ENCODE_STR/g" | $MYSQL $MYSQL_PARAMETERS $DB + ;; + intezmeny) + INTEZMENYROVIDNEV=$(echo $DB | cut -f 2 -d '_') + (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | $MYSQL $MYSQL_PARAMETERS $DB + ;; + *) + (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | $MYSQL $MYSQL_PARAMETERS $DB + ;; + esac + if [ $? != 0 ]; then + exit 13; + fi + done + [ ! -z $SQLLOG ] && echo $FILE >> $SQLLOG; + fi + fi +} + +echo " Az új változat verziószáma: $UJ_REV" + +REVSTR=$(printf "%06d" $REV) +MYSQL_ENCODE_STR=$(grep _MYSQL_ENCODE_STR $BASEDIR/config/main-config.php | sed -e "s/define('_MYSQL_ENCODE_STR','\(.*\)');/\\1/") + +# mysql host beállítása +if [ "$MYSQL_HOST" == "" ]; then + MYSQL_HOST="localhost" +fi +echo " A MySQL backend a következő lesz: $MYSQL_HOST" +echo " Figyelem! MySQL Master-Slave architekturát az upgrade script jelenleg nem támogat!!!" + +echo -e "\n * Adatbázisok lekérdezése..." +if [ -f $MYSQL ] +then + DB_MAYOR=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SHOW DATABASES LIKE 'mayor\_%'" | grep -e '^mayor\_[^_]*$') ## ide elvileg nem kellene precharset, mert itt minden ASCCI/2 + DB_NAPLO=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SHOW DATABASES LIKE 'naplo\_%\_%'" | grep -e '^naplo\_[^\_]*\_20[0-9][0-9]$') + DB_INTEZMENY=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SELECT CONCAT('intezmeny_',rovidNev) FROM mayor_naplo.intezmeny" | grep -e '^intezmeny\_[^\_]*$') +# DB_INTEZMENY=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'intezmeny\_%'" | grep -e '^intezmeny\_[^\_]*$'` + if [ $? != 0 ]; then exit 12; fi + DB_AUTH="" + for DB in $DB_MAYOR; do + if [ "$DB" == "mayor_parent" -o "$DB" == "mayor_private" -o "$DB" == "mayor_public" ]; then + DB_AUTH="$DB_AUTH $DB" + fi + done +else + echo -e "\n\nERROR: A mysql kliens nem található: $MYSQL\n" + exit 12 +fi + +if [ "$SKIPLOCK" != "1" ]; then + if [ ! -z $LOCKFILE ]; then + echo -e "\n * A web-es elérés letiltása:" + echo -n " - Lock-file létrehozása... " + echo "$DATE: Update process runing... " > $LOCKFILE + echo "kész." + + echo -n " - Aktív munkamenetek törlése... " + $MYSQL $MYSQL_PARAMETERS -e"DELETE FROM mayor_login.session" ##itt se kell, jó az ASCII + echo "kész." + fi +else + echo -e "\n * A lock-olást a kérésedre kihagyjuk..." +fi + +echo -e "\n * Az előzetes frissítő állományok feldolgozása (pre*, rev*):\n" +for FILE in $(ls $UPDATEDIR/rev* $UPDATEDIR/pre* | sort); do + run_script +done + +if [ "$EXECONLY" != "1" ]; then + echo -e "\n * A modulok állományainak frissítése:\n" + for MODULE in $MODULES; do + echo -e "\n $MODULE... \n" + if [ "$HTTP_SERVER" == '' ]; then + $SVN --force --quiet export https://svn.mayor.hu/svn/trunk/$MODULE "$BASEDIR" + if [ $? != 0 ]; then exit 13; fi + else + # Ha rpm csomag futtatja, akkor már ki van csomagolva minden és nincs md5sum + if [ -f $TMPDIR/md5sum ]; then + MOD=$(echo $MODULE | sed "s#/#-#") + FILE=$(grep "$MOD-rev" $TMPDIR/md5sum | cut -d ' ' -f 3) + if [ -f $TMPDIR/$FILE ]; then + tar xfz $TMPDIR/$FILE -C $BASEDIR + if [ $? != 0 ]; then exit 13; fi + fi + fi + fi + done + if [ -d $TMPDIR ]; then rm -rf $TMPDIR; fi + echo -e "\nkész.\n" +fi + +echo -e "\n * Az utólagos frissítő állományok feldolgozása (post*):\n" +for FILE in $(ls $UPDATEDIR/post* | sort); do + run_script +done + + +if [ -e $LOCKFILE ]; then + if [ ! -z $LOCKFILE ]; then + echo -e "\n * A web-es hozzáférés engedélyezése:" + rm $LOCKFILE + fi +fi + +if [ "$EXECONLY" != "1" ]; then + echo -e "\n * A szükséges jogosultságok beállítása:" + chmod +x $BASEDIR/bin/mayor + echo -n " ... " + chown -R $WEB_SERVER_USER $BASEDIR/download + chown -R $WEB_SERVER_USER $BASEDIR/cache + if [ -d $BASEDIR/www/wiki/conf ]; then + chown -R $WEB_SERVER_USER $BASEDIR/www/wiki/conf $BASEDIR/www/wiki/data + fi + chown $WEB_SERVER_USER $BASEDIR/config + chmod 700 $BASEDIR/config + echo -e "... kész.\n" + + echo -e "\n * Szimbolikus linkek ellenőrzése/létrehozása" + POLICIES="parent public" + for POLICY in $POLICIES; do + eval "LIST=\$${POLICY}Link" + for f in $LIST; do + DIR=$(echo $f | cut -d / -f 1-2) + if [ ! -d $BASEDIR/www/policy/$POLICY/$DIR ]; then + echo " Könyvtár: $BASEDIR/www/policy/$POLICY/$DIR" + mkdir -p $BASEDIR/www/policy/$POLICY/$DIR + fi + FILES="$f-pre.php $f.php" + for file in $FILES; do + if [ ! -e $BASEDIR/www/policy/$POLICY/$file ]; then + if [ -f $BASEDIR/www/policy/private/$file ]; then + echo " $BASEDIR/www/policy/private/$file --> $BASEDIR/www/policy/$POLICY/$file" + ln -s $BASEDIR/www/policy/private/$file $BASEDIR/www/policy/$POLICY/$file + else + echo " Hiányzó file: $BASEDIR/www/policy/private/$file" + fi + fi + done + done + eval "DLIST=\$${POLICY}Deny" + for f in $DLIST; do + FILES="$f-pre.php $f.php" + for file in $FILES; do + if [ -e $BASEDIR/www/policy/$POLICY/$file ]; then + echo " $BASEDIR/www/policy/$POLICY/$file link(file) törlése" + rm "$BASEDIR/www/policy/$POLICY/$file" + fi + done + done + done +fi # execonly + +echo -e "\n * Az frissített verziószám rögzítése ($UJ_REV)" +if [ "$UJ_REV" -gt 0 ]; then + echo $UJ_REV > $REVISION_FILE +else + echo " Hibás (nulla) verziószám! Nem rögzítjük." +fi + +[ -x "$LOCAL_UPDATE_SCRIPT" ] && echo -e "\n * Helyi szkript futtatása: $LOCAL_UPDATE_SCRIPT...\n " && . "$LOCAL_UPDATE_SCRIPT" diff --git a/mayor-mod/update/processUpdateScripts.sh.mod.txt b/mayor-mod/update/processUpdateScripts.sh.mod.txt new file mode 100644 index 00000000..3168b48d --- /dev/null +++ b/mayor-mod/update/processUpdateScripts.sh.mod.txt @@ -0,0 +1,183 @@ +--- processUpdateScripts.sh.orig 2016-03-04 13:44:39.000000000 +0100 ++++ processUpdateScripts.sh 2018-03-04 14:10:13.835309914 +0100 +@@ -6,22 +6,26 @@ + echo -e "[mysqld] + character-set-server = utf8 + collation-server = utf8_hungarian_ci +-skip-character-set-client-handshake + [client] ++default-character-set=utf8 + host=$MYSQL_HOST + user=$MYSQL_USER + password=$MYSQL_PW + " > $BASEDIR/config/my.cnf ++ ++PRECHARSET="SET NAMES 'utf8' COLLATE 'utf8_hungarian_ci'; " ## fontos, hogy a ";" ott legyen a végén!! ++#PRECHARSET="$PRECHARSET SET collation_connection = utf8_hungarian_ci; " ## ha a mysql server esetleg régebbi lenne. ++ + MYSQL_CONFIG="--defaults-extra-file=$BASEDIR/config/my.cnf" + MYSQL_PARAMETERS="" +-TEST=`$MYSQL -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW -e exit 2>&1 >/dev/null` ++TEST=$($MYSQL -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW -e exit 2>&1 >/dev/null) + if [ $? == "0" ]; then + echo "SQL-connect test #2 OK" + MYSQL_PARAMETERS="-h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW" + else + echo "Hibás SQL csatlakozás(2)" + fi +-TEST=`$MYSQL $MYSQL_CONFIG -e exit 2>&1 >/dev/null` ++TEST=$($MYSQL $MYSQL_CONFIG -e exit 2>&1 >/dev/null) + if [ $? == "0" ]; then + echo "SQL-connect test #1 OK" + MYSQL_PARAMETERS=$MYSQL_CONFIG +@@ -31,8 +35,12 @@ + echo "Karakterkódolás ellenőrzése" + echo "SHOW VARIABLES LIKE 'character%';" | $MYSQL $MYSQL_PARAMETERS + # patch by Acsai Gabor - FreeBSD +-TEST=`echo "SHOW VARIABLES LIKE 'character_set_client'" | $MYSQL $MYSQL_PARAMETERS | grep utf8 | wc -l | tr -d " "` +-if [ "x${TEST}" == "x1" ]; then ++# Kiegészítve: Miklós Gergő - Baár-Madas ++# gondolatmenet: ++# A "default-character-set" beállítása után a "character_set_client" változóból 1db kell legyen, és értéke pontosan "utf8" kell legyen! ++### TEST=`echo "SHOW VARIABLES LIKE 'character_set_client'" | $MYSQL $MYSQL_PARAMETERS | grep utf8 | wc -l | tr -d " "` ++TEST=$(echo "SHOW VARIABLES LIKE '%character_set_client%'" | $MYSQL $MYSQL_PARAMETERS | tail -n+2 | cut -f 2) ++if [ "$TEST" == "utf8" ]; then + echo "SQL-UTF8 test OK" + else + echo -e "\n\nERROR: Hibás - nem utf8 - MySQL kliens karakterkódolás!\n" +@@ -42,7 +50,7 @@ + # -- + + run_script() { +- FILEELEJE=`echo $FILE | cut -f 1 -d '-'` ++ FILEELEJE=$(echo $FILE | cut -f 1 -d '-') + FILEREV=${FILEELEJE: -6} + LOGSQL="" + if [ "$FILEREV" != "" ]; then +@@ -51,14 +59,14 @@ + fi + fi + if [ ! "${FILEREV}" \< "${REVSTR}" ]; then +- FILEEXT=`echo $FILE | cut -f 2 -d '.'` ++ FILEEXT=$(echo $FILE | cut -f 2 -d '.') + if [ "$FILEEXT" == "sh" ]; then + echo " - Szkript futtatása ($FILE)..." + . $FILE + if [ $? != 0 ]; then exit 13; fi + elif [ "$FILEEXT" == "sql" ]; then + echo " - SQL utasítások végrehajtása ($FILE)..." +- FILEDB=`echo $FILE | cut -f 1 -d '.' | cut -f 3 -d '-'` ++ FILEDB=$(echo $FILE | cut -f 1 -d '.' | cut -f 3 -d '-') + case "$FILEDB" in + naplo) + DBS=$DB_NAPLO +@@ -78,7 +86,7 @@ + + if [ "$FILEREV" != "" ]; then + if [ "$FILEREV" -gt 3399 ]; then +- TEST=`echo "SELECT count(*) as db FROM information_schema.TABLES WHERE TABLE_SCHEMA='${DB}' and TABLE_NAME='mayorUpdateLog'" | $MYSQL $MYSQL_PARAMETERS $DB | grep -v "db"` ++ TEST=$((echo $PRECHARSET && echo "SELECT count(*) as db FROM information_schema.TABLES WHERE TABLE_SCHEMA='${DB}' and TABLE_NAME='mayorUpdateLog'") | $MYSQL $MYSQL_PARAMETERS $DB | grep -v "db") + if [ "$TEST" == "0" ]; then + echo " Hiányzik a mayorUpdateLog tábla... tovább..." + continue +@@ -88,21 +96,21 @@ + + case "$FILEDB" in + naplo) +- INTEZMENYDB=`echo $DB | sed -e 's/\(naplo_\)\(.*\)\(_.*\)/intezmeny_\2/'` +- INTEZMENYROVIDNEV=`echo $DB | cut -f 2 -d '_'` +- TANEV=`echo $DB | cut -f 3 -d '_'` +- (cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENYDB%/$INTEZMENYDB/g" | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | \ ++ INTEZMENYDB=$(echo $DB | sed -e 's/\(naplo_\)\(.*\)\(_.*\)/intezmeny_\2/') ++ INTEZMENYROVIDNEV=$(echo $DB | cut -f 2 -d '_') ++ TANEV=$(echo $DB | cut -f 3 -d '_') ++ (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENYDB%/$INTEZMENYDB/g" | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | \ + sed -e "s/%TANEV%/$TANEV/g" | $MYSQL $MYSQL_PARAMETERS $DB + ;; + auth) +- (cat $FILE && echo "${LOGSQL}") | sed -e "s/%MYSQL_ENCODE_STR%/$MYSQL_ENCODE_STR/g" | $MYSQL $MYSQL_PARAMETERS $DB ++ (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%MYSQL_ENCODE_STR%/$MYSQL_ENCODE_STR/g" | $MYSQL $MYSQL_PARAMETERS $DB + ;; + intezmeny) +- INTEZMENYROVIDNEV=`echo $DB | cut -f 2 -d '_'` +- (cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | $MYSQL $MYSQL_PARAMETERS $DB ++ INTEZMENYROVIDNEV=$(echo $DB | cut -f 2 -d '_') ++ (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | $MYSQL $MYSQL_PARAMETERS $DB + ;; + *) +- (cat $FILE && echo "${LOGSQL}") | $MYSQL $MYSQL_PARAMETERS $DB ++ (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | $MYSQL $MYSQL_PARAMETERS $DB + ;; + esac + if [ $? != 0 ]; then +@@ -116,8 +124,8 @@ + + echo " Az új változat verziószáma: $UJ_REV" + +-REVSTR=`printf "%06d" $REV` +-MYSQL_ENCODE_STR=`grep _MYSQL_ENCODE_STR $BASEDIR/config/main-config.php | sed -e "s/define('_MYSQL_ENCODE_STR','\(.*\)');/\\1/"` ++REVSTR=$(printf "%06d" $REV) ++MYSQL_ENCODE_STR=$(grep _MYSQL_ENCODE_STR $BASEDIR/config/main-config.php | sed -e "s/define('_MYSQL_ENCODE_STR','\(.*\)');/\\1/") + + # mysql host beállítása + if [ "$MYSQL_HOST" == "" ]; then +@@ -129,9 +137,9 @@ + echo -e "\n * Adatbázisok lekérdezése..." + if [ -f $MYSQL ] + then +- DB_MAYOR=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'mayor\_%'" | grep -e '^mayor\_[^_]*$'` +- DB_NAPLO=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'naplo\_%\_%'" | grep -e '^naplo\_[^\_]*\_20[0-9][0-9]$'` +- DB_INTEZMENY=`$MYSQL $MYSQL_PARAMETERS -e"SELECT CONCAT('intezmeny_',rovidNev) FROM mayor_naplo.intezmeny" | grep -e '^intezmeny\_[^\_]*$'` ++ DB_MAYOR=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SHOW DATABASES LIKE 'mayor\_%'" | grep -e '^mayor\_[^_]*$') ## ide elvileg nem kellene precharset, mert itt minden ASCCI/2 ++ DB_NAPLO=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SHOW DATABASES LIKE 'naplo\_%\_%'" | grep -e '^naplo\_[^\_]*\_20[0-9][0-9]$') ++ DB_INTEZMENY=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SELECT CONCAT('intezmeny_',rovidNev) FROM mayor_naplo.intezmeny" | grep -e '^intezmeny\_[^\_]*$') + # DB_INTEZMENY=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'intezmeny\_%'" | grep -e '^intezmeny\_[^\_]*$'` + if [ $? != 0 ]; then exit 12; fi + DB_AUTH="" +@@ -153,7 +161,7 @@ + echo "kész." + + echo -n " - Aktív munkamenetek törlése... " +- $MYSQL $MYSQL_PARAMETERS -e"DELETE FROM mayor_login.session" ++ $MYSQL $MYSQL_PARAMETERS -e"DELETE FROM mayor_login.session" ##itt se kell, jó az ASCII + echo "kész." + fi + else +@@ -161,7 +169,7 @@ + fi + + echo -e "\n * Az előzetes frissítő állományok feldolgozása (pre*, rev*):\n" +-for FILE in `ls $UPDATEDIR/rev* $UPDATEDIR/pre* | sort`; do ++for FILE in $(ls $UPDATEDIR/rev* $UPDATEDIR/pre* | sort); do + run_script + done + +@@ -175,8 +183,8 @@ + else + # Ha rpm csomag futtatja, akkor már ki van csomagolva minden és nincs md5sum + if [ -f $TMPDIR/md5sum ]; then +- MOD=`echo $MODULE | sed "s#/#-#"` +- FILE=`grep "$MOD-rev" $TMPDIR/md5sum | cut -d ' ' -f 3` ++ MOD=$(echo $MODULE | sed "s#/#-#") ++ FILE=$(grep "$MOD-rev" $TMPDIR/md5sum | cut -d ' ' -f 3) + if [ -f $TMPDIR/$FILE ]; then + tar xfz $TMPDIR/$FILE -C $BASEDIR + if [ $? != 0 ]; then exit 13; fi +@@ -189,7 +197,7 @@ + fi + + echo -e "\n * Az utólagos frissítő állományok feldolgozása (post*):\n" +-for FILE in `ls $UPDATEDIR/post* | sort`; do ++for FILE in $(ls $UPDATEDIR/post* | sort); do + run_script + done + +@@ -219,7 +227,7 @@ + for POLICY in $POLICIES; do + eval "LIST=\$${POLICY}Link" + for f in $LIST; do +- DIR=`echo $f | cut -d / -f 1-2` ++ DIR=$(echo $f | cut -d / -f 1-2) + if [ ! -d $BASEDIR/www/policy/$POLICY/$DIR ]; then + echo " Könyvtár: $BASEDIR/www/policy/$POLICY/$DIR" + mkdir -p $BASEDIR/www/policy/$POLICY/$DIR diff --git a/mayor-mod/update/processUpdateScripts.sh.orig b/mayor-mod/update/processUpdateScripts.sh.orig new file mode 100644 index 00000000..47fbb23e --- /dev/null +++ b/mayor-mod/update/processUpdateScripts.sh.orig @@ -0,0 +1,259 @@ +#!/bin/bash + +source $BASEDIR/update/linkme.sh + +# Setting Mysql Connection Parameters +echo -e "[mysqld] +character-set-server = utf8 +collation-server = utf8_hungarian_ci +skip-character-set-client-handshake +[client] +host=$MYSQL_HOST +user=$MYSQL_USER +password=$MYSQL_PW +" > $BASEDIR/config/my.cnf +MYSQL_CONFIG="--defaults-extra-file=$BASEDIR/config/my.cnf" +MYSQL_PARAMETERS="" +TEST=`$MYSQL -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW -e exit 2>&1 >/dev/null` +if [ $? == "0" ]; then + echo "SQL-connect test #2 OK" + MYSQL_PARAMETERS="-h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW" +else + echo "Hibás SQL csatlakozás(2)" +fi +TEST=`$MYSQL $MYSQL_CONFIG -e exit 2>&1 >/dev/null` +if [ $? == "0" ]; then + echo "SQL-connect test #1 OK" + MYSQL_PARAMETERS=$MYSQL_CONFIG +else + echo "Hibás SQL csatlakozás(1)" +fi +echo "Karakterkódolás ellenőrzése" +echo "SHOW VARIABLES LIKE 'character%';" | $MYSQL $MYSQL_PARAMETERS +# patch by Acsai Gabor - FreeBSD +TEST=`echo "SHOW VARIABLES LIKE 'character_set_client'" | $MYSQL $MYSQL_PARAMETERS | grep utf8 | wc -l | tr -d " "` +if [ "x${TEST}" == "x1" ]; then + echo "SQL-UTF8 test OK" +else + echo -e "\n\nERROR: Hibás - nem utf8 - MySQL kliens karakterkódolás!\n" + echo -e "Ellenőrizd a beállításokat és kérj segítséget a support@mayor.hu -n!\n" + exit 12 +fi +# -- + +run_script() { + FILEELEJE=`echo $FILE | cut -f 1 -d '-'` + FILEREV=${FILEELEJE: -6} + LOGSQL="" + if [ "$FILEREV" != "" ]; then + if [ "$FILEREV" -gt 3399 ]; then + LOGSQL="INSERT IGNORE mayorUpdateLog (scriptFile) VALUES ('${FILE}')" + fi + fi + if [ ! "${FILEREV}" \< "${REVSTR}" ]; then + FILEEXT=`echo $FILE | cut -f 2 -d '.'` + if [ "$FILEEXT" == "sh" ]; then + echo " - Szkript futtatása ($FILE)..." + . $FILE + if [ $? != 0 ]; then exit 13; fi + elif [ "$FILEEXT" == "sql" ]; then + echo " - SQL utasítások végrehajtása ($FILE)..." + FILEDB=`echo $FILE | cut -f 1 -d '.' | cut -f 3 -d '-'` + case "$FILEDB" in + naplo) + DBS=$DB_NAPLO + ;; + intezmeny) + DBS=$DB_INTEZMENY + ;; + auth) + DBS=$DB_AUTH + ;; + *) + DBS=$FILEDB + ;; + esac + for DB in $DBS; do + echo -e "\n $DB..." + + if [ "$FILEREV" != "" ]; then + if [ "$FILEREV" -gt 3399 ]; then + TEST=`echo "SELECT count(*) as db FROM information_schema.TABLES WHERE TABLE_SCHEMA='${DB}' and TABLE_NAME='mayorUpdateLog'" | $MYSQL $MYSQL_PARAMETERS $DB | grep -v "db"` + if [ "$TEST" == "0" ]; then + echo " Hiányzik a mayorUpdateLog tábla... tovább..." + continue + fi + fi + fi + + case "$FILEDB" in + naplo) + INTEZMENYDB=`echo $DB | sed -e 's/\(naplo_\)\(.*\)\(_.*\)/intezmeny_\2/'` + INTEZMENYROVIDNEV=`echo $DB | cut -f 2 -d '_'` + TANEV=`echo $DB | cut -f 3 -d '_'` + (cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENYDB%/$INTEZMENYDB/g" | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | \ + sed -e "s/%TANEV%/$TANEV/g" | $MYSQL $MYSQL_PARAMETERS $DB + ;; + auth) + (cat $FILE && echo "${LOGSQL}") | sed -e "s/%MYSQL_ENCODE_STR%/$MYSQL_ENCODE_STR/g" | $MYSQL $MYSQL_PARAMETERS $DB + ;; + intezmeny) + INTEZMENYROVIDNEV=`echo $DB | cut -f 2 -d '_'` + (cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | $MYSQL $MYSQL_PARAMETERS $DB + ;; + *) + (cat $FILE && echo "${LOGSQL}") | $MYSQL $MYSQL_PARAMETERS $DB + ;; + esac + if [ $? != 0 ]; then + exit 13; + fi + done + [ ! -z $SQLLOG ] && echo $FILE >> $SQLLOG; + fi + fi +} + +echo " Az új változat verziószáma: $UJ_REV" + +REVSTR=`printf "%06d" $REV` +MYSQL_ENCODE_STR=`grep _MYSQL_ENCODE_STR $BASEDIR/config/main-config.php | sed -e "s/define('_MYSQL_ENCODE_STR','\(.*\)');/\\1/"` + +# mysql host beállítása +if [ "$MYSQL_HOST" == "" ]; then + MYSQL_HOST="localhost" +fi +echo " A MySQL backend a következő lesz: $MYSQL_HOST" +echo " Figyelem! MySQL Master-Slave architekturát az upgrade script jelenleg nem támogat!!!" + +echo -e "\n * Adatbázisok lekérdezése..." +if [ -f $MYSQL ] +then + DB_MAYOR=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'mayor\_%'" | grep -e '^mayor\_[^_]*$'` + DB_NAPLO=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'naplo\_%\_%'" | grep -e '^naplo\_[^\_]*\_20[0-9][0-9]$'` + DB_INTEZMENY=`$MYSQL $MYSQL_PARAMETERS -e"SELECT CONCAT('intezmeny_',rovidNev) FROM mayor_naplo.intezmeny" | grep -e '^intezmeny\_[^\_]*$'` +# DB_INTEZMENY=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'intezmeny\_%'" | grep -e '^intezmeny\_[^\_]*$'` + if [ $? != 0 ]; then exit 12; fi + DB_AUTH="" + for DB in $DB_MAYOR; do + if [ "$DB" == "mayor_parent" -o "$DB" == "mayor_private" -o "$DB" == "mayor_public" ]; then + DB_AUTH="$DB_AUTH $DB" + fi + done +else + echo -e "\n\nERROR: A mysql kliens nem található: $MYSQL\n" + exit 12 +fi + +if [ "$SKIPLOCK" != "1" ]; then + if [ ! -z $LOCKFILE ]; then + echo -e "\n * A web-es elérés letiltása:" + echo -n " - Lock-file létrehozása... " + echo "$DATE: Update process runing... " > $LOCKFILE + echo "kész." + + echo -n " - Aktív munkamenetek törlése... " + $MYSQL $MYSQL_PARAMETERS -e"DELETE FROM mayor_login.session" + echo "kész." + fi +else + echo -e "\n * A lock-olást a kérésedre kihagyjuk..." +fi + +echo -e "\n * Az előzetes frissítő állományok feldolgozása (pre*, rev*):\n" +for FILE in `ls $UPDATEDIR/rev* $UPDATEDIR/pre* | sort`; do + run_script +done + +if [ "$EXECONLY" != "1" ]; then + echo -e "\n * A modulok állományainak frissítése:\n" + for MODULE in $MODULES; do + echo -e "\n $MODULE... \n" + if [ "$HTTP_SERVER" == '' ]; then + $SVN --force --quiet export https://svn.mayor.hu/svn/trunk/$MODULE "$BASEDIR" + if [ $? != 0 ]; then exit 13; fi + else + # Ha rpm csomag futtatja, akkor már ki van csomagolva minden és nincs md5sum + if [ -f $TMPDIR/md5sum ]; then + MOD=`echo $MODULE | sed "s#/#-#"` + FILE=`grep "$MOD-rev" $TMPDIR/md5sum | cut -d ' ' -f 3` + if [ -f $TMPDIR/$FILE ]; then + tar xfz $TMPDIR/$FILE -C $BASEDIR + if [ $? != 0 ]; then exit 13; fi + fi + fi + fi + done + if [ -d $TMPDIR ]; then rm -rf $TMPDIR; fi + echo -e "\nkész.\n" +fi + +echo -e "\n * Az utólagos frissítő állományok feldolgozása (post*):\n" +for FILE in `ls $UPDATEDIR/post* | sort`; do + run_script +done + + +if [ -e $LOCKFILE ]; then + if [ ! -z $LOCKFILE ]; then + echo -e "\n * A web-es hozzáférés engedélyezése:" + rm $LOCKFILE + fi +fi + +if [ "$EXECONLY" != "1" ]; then + echo -e "\n * A szükséges jogosultságok beállítása:" + chmod +x $BASEDIR/bin/mayor + echo -n " ... " + chown -R $WEB_SERVER_USER $BASEDIR/download + chown -R $WEB_SERVER_USER $BASEDIR/cache + if [ -d $BASEDIR/www/wiki/conf ]; then + chown -R $WEB_SERVER_USER $BASEDIR/www/wiki/conf $BASEDIR/www/wiki/data + fi + chown $WEB_SERVER_USER $BASEDIR/config + chmod 700 $BASEDIR/config + echo -e "... kész.\n" + + echo -e "\n * Szimbolikus linkek ellenőrzése/létrehozása" + POLICIES="parent public" + for POLICY in $POLICIES; do + eval "LIST=\$${POLICY}Link" + for f in $LIST; do + DIR=`echo $f | cut -d / -f 1-2` + if [ ! -d $BASEDIR/www/policy/$POLICY/$DIR ]; then + echo " Könyvtár: $BASEDIR/www/policy/$POLICY/$DIR" + mkdir -p $BASEDIR/www/policy/$POLICY/$DIR + fi + FILES="$f-pre.php $f.php" + for file in $FILES; do + if [ ! -e $BASEDIR/www/policy/$POLICY/$file ]; then + if [ -f $BASEDIR/www/policy/private/$file ]; then + echo " $BASEDIR/www/policy/private/$file --> $BASEDIR/www/policy/$POLICY/$file" + ln -s $BASEDIR/www/policy/private/$file $BASEDIR/www/policy/$POLICY/$file + else + echo " Hiányzó file: $BASEDIR/www/policy/private/$file" + fi + fi + done + done + eval "DLIST=\$${POLICY}Deny" + for f in $DLIST; do + FILES="$f-pre.php $f.php" + for file in $FILES; do + if [ -e $BASEDIR/www/policy/$POLICY/$file ]; then + echo " $BASEDIR/www/policy/$POLICY/$file link(file) törlése" + rm "$BASEDIR/www/policy/$POLICY/$file" + fi + done + done + done +fi # execonly + +echo -e "\n * Az frissített verziószám rögzítése ($UJ_REV)" +if [ "$UJ_REV" -gt 0 ]; then + echo $UJ_REV > $REVISION_FILE +else + echo " Hibás (nulla) verziószám! Nem rögzítjük." +fi + +[ -x "$LOCAL_UPDATE_SCRIPT" ] && echo -e "\n * Helyi szkript futtatása: $LOCAL_UPDATE_SCRIPT...\n " && . "$LOCAL_UPDATE_SCRIPT" diff --git a/mayor-mod/www/include/modules/naplo/share/file.php b/mayor-mod/www/include/modules/naplo/share/file.php new file mode 100644 index 00000000..1e6c7595 --- /dev/null +++ b/mayor-mod/www/include/modules/naplo/share/file.php @@ -0,0 +1,662 @@ + _ATTR_DIAKID, + 'oid' => _ATTR_OID, + 'diakigazolvanyszam' => _ATTR_IGAZOLVANYSZAM, + 'viseltnevelotag' => _ATTR_VNE, + 'viseltcsaladinev' => _ATTR_VCSN, + 'viseltutonev' => _ATTR_VUN, + 'szuleteskorinevelotag' => _ATTR_SZNE, + 'szuleteskoricsaladinev' => _ATTR_SZCSN, + 'szuleteskoriutonev' => _ATTR_SZUN, + 'szuletesihely' => _ATTR_SZH, + 'szuletesiido' => _ATTR_SZI, + 'anyanevelotag' => _ATTR_ANE, + 'anyacsaladinev' => _ATTR_ACSN, + 'anyautoneve' => _ATTR_AUN, + 'kezdotanev' => _ATTR_KEZDO_TANEV, + 'kezdoszemeszter' => _ATTR_KEZDO_SZEMESZTER, + 'vegzotanev' => _ATTR_VEGZO_TANEV, + 'vegzoszemeszter' => _ATTR_VEGZO_SZEMESZTER, + 'adoazonosito' => _ATTR_ADOAZONOSITO, + 'allampolgarsag' => _ATTR_ALLAMPOLGARSAG, + 'anyaid' => _ATTR_ANYAID, + 'apaid' => _ATTR_APAID, + 'gondviseloid' => _ATTR_GONDVISELOID, + 'neveloid' => _ATTR_NEVELOID, + 'diaknaplosorszam' => _ATTR_DIAKNAPLOSORSZAM, + 'elozoiskolaomkod' => _ATTR_ELOZOISKOLAOMKOD, + 'email' => _ATTR_EMAIL, + 'fogyatekossag' => _ATTR_FOGYATEKOSSAG, + 'gondozasiszam' => _ATTR_GONDOZASISZAM, + 'jogviszonykezdete' => _ATTR_JOGVISZONYKEZDETE, + 'jogviszonyvege' => _ATTR_JOGVISZONYVEGE, + + 'lakhelyorszag' => _ATTR_LAKHELY_ORSZAG, + 'lakhelyirsz' => _ATTR_LAKHELY_IRSZ, + 'lakhelyhelyseg' => _ATTR_LAKHELY_HELYSEG, + 'lakhelykozteruletnev' => _ATTR_LAKHELY_KOZTERULETNEV, + 'lakhelykozteruletjelleg' => _ATTR_LAKHELY_KOZTERULETJELLEG, + 'lakhelyhazszam' => _ATTR_LAKHELY_HAZSZAM, + 'lakhelyemelet' => _ATTR_LAKHELY_EMELET, + 'lakhelyajto' => _ATTR_LAKHELY_AJTO, + + 'tartorszag' => _ATTR_TART_ORSZAG, + 'tartirsz' => _ATTR_TART_IRSZ, + 'tarthelyseg' => _ATTR_TART_HELYSEG, + 'tartkozteruletnev' => _ATTR_TART_KOZTERULETNEV, + 'tartkozteruletjelleg' => _ATTR_TART_KOZTERULETJELLEG, + 'tarthazszam' => _ATTR_TART_HAZSZAM, + 'tartemelet' => _ATTR_TART_EMELET, + 'tartajto' => _ATTR_TART_AJTO, + + 'tajszam' => _ATTR_TAJSZAM, + 'osztalyjel' => _ATTR_OSZTALYJEL, + 'penzugyistatusz' => _ATTR_PENZUGYISTATUSZ, + 'szemelyiigazolvanyszam' => _ATTR_SZEMELYIIGAZOLVANYSZAM, + 'szocialishelyzet' => _ATTR_SZOCIALISHELYZET, + 'statusz' => _ATTR_STATUSZ, + 'tartozkodasiokiratszam' => _ATTR_TARTOZKODASIOKIRATSZAM, + 'torvenyeskepviselo' => _ATTR_TORVENYESKEPVISELO, + 'telefon' => _ATTR_TELEFON, + 'mobil' => _ATTR_MOBIL, + 'nem' => _ATTR_NEM, + 'lakohelyijellemzo' => _ATTR_LAKOHELYIJELLEMZO, + 'megjegyzes' => _ATTR_MEGJEGYZES, + ); + + function readUpdateFile($fileName, $mezo_elvalaszto = ' ') { + + + $ADATOK = array(); + if ($fp = @fopen($fileName,'r')) { + // Az első 50 sor beolvasása - minta a mező-hozzárendeléshez + $i=0; + while (($sor = fgets($fp,1024)) and ($i<50)) { + $ADATOK[$i] = explode($mezo_elvalaszto,chop($sor)); + $i++; + } + fclose($fp); + } else { + $_SESSION['alert'][] = 'message:file_open_error:'.$fileName; + } + + return $ADATOK; + } +/* + * Lekérdezi egy adatbázis (naplo_intezmeny, naplo (tanév)) egy adott táblájának mezőit. + * Ha szükséges ezek listáját kiegészíti az extraAttrs tömbben felsorolt mezőkkel. + * A mezőnevekhez nyelvi konstansokat rendelhetünk ($Attrs tömb és lang/.../share/file.php) + */ + function getTableFields($table, $db = 'naplo_intezmeny', $extraAttrs = array(), $SET = array('withType' => false)) { + + global $Attrs; + + $return = $type = $name = array(); + $q = "SHOW FIELDS FROM `%s`"; + $r = db_query($q, array('fv' => 'getTableFields','modul' => $db, 'result' => 'indexed', 'values' => array($table))); + for ($i = 0; $i < count($r); $i++) { + if ($SET['withType']) { + if (substr($r[$i]['Type'],0,7) == 'varchar') $type[ $r[$i]['Field'] ] = 'string'; + elseif (substr($r[$i]['Type'],0,4) == 'enum') $type[ $r[$i]['Field'] ] = 'enum'; + elseif (substr($r[$i]['Type'],0,4) == 'date') $type[ $r[$i]['Field'] ] = 'date'; + elseif (strpos($r[$i]['Type'],'int(') !== false) $type[ $r[$i]['Field'] ] = 'int'; + else $type[ $r[$i]['Field'] ] = 'string'; + } + if ($Attrs[kisbetus($r[$i]['Field'])] != '') $name[$r[$i]['Field']] = $Attrs[kisbetus($r[$i]['Field'])]; + else $name[$r[$i]['Field']] = $r[$i]['Field']; + } + for ($i = 0; $i < count($extraAttrs); $i++) { + if (!isset($name[$extraAttrs[$i]])) { + if ($Attrs[kisbetus($extraAttrs[$i])] != '') $name[$extraAttrs[$i]] = $Attrs[kisbetus($extraAttrs[$i])]; + else $name[$extraAttrs[$i]] = $extraAttrs[$i]; + } + } + ksort($name); + + if ($SET['withType']) return array('names' => $name, 'types' => $type); + return $name; + + } + + + function getEnumField($modul, $table, $field) { + + $table = '`'.str_replace('.','`.`',$table).'`'; + $q = "SHOW FIELDS FROM %s LIKE '%s'"; + $v = array($table, $field); + $field = db_query($q, array('fv' => 'getEnumField', 'modul' => $modul, 'result' => 'record', 'values' => $v)); + $enum = substr($field['Type'], 6, -2); + $values = explode("','", $enum); + + return $values; + } + + function getSetField($modul, $table, $field) { + + $table = '`'.str_replace('.','`.`',$table).'`'; + $q = "SHOW FIELDS FROM %s LIKE '%s'"; + $v = array($table, $field); + $field = db_query($q, array('fv' => 'getSetField', 'modul' => $modul, 'result' => 'record', 'values' => $v)); + $set = substr($field['Type'], 5, -2); + $values = explode("','", $set); + + return $values; + } + + + function updateTable($table, $file, $MEZO_LISTA, $KULCS_MEZOK, $mezo_elvalaszto = ' ', $rovatfej = false, $db = 'naplo_intezmeny') { + + + if (!file_exists($file)) { + $_SESSION['alert'][] = 'message:file_not_found:updateTable:'.$file; + return false; + } + + if (!is_array($MEZO_LISTA)) { + $_SESSION['alert'][] = 'message:wrong_data:updateTable:MEZO_LISTA'; + return false; + } + + if (!is_array($KULCS_MEZOK)) { + $_SESSION['alert'][] = 'message:wrong_data:updateTable:KULCS_MEZOK'; + return false; + } + + // A frissítendő attribútumok listája + $attrList = array_values(array_filter($MEZO_LISTA)); + + $fp = fopen($file,'r'); + if (!$fp) { + $_SESSION['alert'][] = 'message:file_open_error:updateTable:'.$file; + return false; + } + + $lr = db_connect($db, array('fv' => 'updateTable')); + if (!$lr) { + $_SESSION['alert'][] = 'message:db_connect_failure:updateTable'; + fclose($fp); + return false; + } + db_start_trans($lr); + + // Az első sor kihagyása + if ($rovatfej) $sor = fgets($fp,1024); + while ($sor = fgets($fp,1024)) { + + $insertValues = $insertPatterns = array(); + $adatSor = explode($mezo_elvalaszto,chop($sor)); + $update = false; + + // keresési feltétel összerakása + $where = $v = $vw = array(); + for ($i = 0; $i < count($KULCS_MEZOK); $i++) { + if ($adatSor[$KULCS_MEZOK[$i]] != '') { + $where[] = "`%s`='%s'"; + array_push($vw, $MEZO_LISTA[$KULCS_MEZOK[$i]], $adatSor[$KULCS_MEZOK[$i]]); + } + } + $num = 0; + if (count($where) != 0) { + $q = 'SELECT COUNT(*) FROM `%s` WHERE '.implode(' AND ', $where); + array_unshift($vw, $table); + $num = db_query($q, array('fv' => 'updateTable', 'values' => $vw, 'result' => 'value', 'modul' => $db), $lr); + } + if ($num == 1 && _SKIP_ON_DUP === true) { $_SESSION['alert'][] = 'info:_SKIP_ON_DUP:'.serialize($sor); continue; } + if ($num == 1) { // update + $v = $vw; + array_shift($v); //$table kivétele + $UPDATE = array(); + for ($i = 0; $i < count($MEZO_LISTA); $i++) { + if ( + $MEZO_LISTA[$i] != '' + and $adatSor[$i] != '' + and !in_array($i,$KULCS_MEZOK) + ) { + if ($adatSor[$i] == '\N') { + array_unshift($UPDATE, "`%s`=NULL"); + array_unshift($v, $MEZO_LISTA[$i]); + } else { + array_unshift($UPDATE, "`%s`='%s'"); + array_unshift($v, $MEZO_LISTA[$i], $adatSor[$i]); + } + } + } + if (count($UPDATE) > 0) { + array_unshift($v, $table); + $q = 'UPDATE `%s` SET '.implode(',',$UPDATE).' WHERE '.implode(' AND ', $where); + $r = db_query($q, array('fv' => 'updateTable/update', 'values' => $v, 'modul' => $db, 'rollback' => true), $lr); + if (!$r) { + db_close($lr); + return false; + } + } + } elseif ($num == 0) { // insert + for ($i = 0; $i < count($MEZO_LISTA); $i++) { + if ($MEZO_LISTA[$i] != '') { + if ($adatSor[$i] == '\N') { + $insertValues[] = 'NULL'; + $insertPatterns[] = '%s'; + } else { + $insertValues[] = $adatSor[$i]; + $insertPatterns[] = "'%s'"; + } + } + } + $q = 'INSERT INTO `%s` ('.implode(',', array_fill(0, count($attrList), '%s')).') + VALUES ('.implode(',', $insertPatterns).')'; + $v = mayor_array_join(array($table), $attrList, $insertValues); + $r = db_query($q, array('fv' => 'updateTable/insert', 'modul' => $db, 'values' => $v, 'rollback' => true), $lr); + if (!$r) { + db_close($lr); + return false; + } + } else { + $_SESSION['alert'][] = 'message:wrong_data:updateTable:több illeszkedő rekord is van, túl laza a kulcs feltétel (' + .call_user_func_array('sprintf', array_merge(array('%s tábla, '.implode(' AND ',$where)), $vw)).')'; + db_rollback($lr); + db_close($lr); + return false; + } + } // while + db_commit($lr); + db_close($lr); + + fclose($fp); + + } + + function generatePDF($outputFile, $outputDir, $str, $booklet=false) { + + + // A szöveg file-ba írása + if (!$fp = fopen($outputDir.'/'.$outputFile.'-u8.tex', 'w')) { + $_SESSION['alert'][] = 'message:file_open_failure:generatePDF:'.$outputDir.'/'.$outputFile.'-u8.tex'; + return false; + } + if (!fwrite($fp, $str)) { + $_SESSION['alert'][] = 'message:file_write_failure:generatePDF:'.$outputDir.'/'.$outputFile.'-u8.tex'; + return false; + } + fclose($fp); + if (__NYOMTATAS_XETEX===true) { + $ret = exec('cd '.$outputDir.'; cat < '.$outputFile.'.tex +%\font\kicsi=ecrm0500 +%\font\nagy=ecbx1200 +%\font\vastag=ecsx0800 +%\font\nagyss=ecsx1200 +%\font\normal=ecss0800 +%\font\dolt=ecsi0800 + +\font\kicsi="Linux Libertine O" at 5pt +\font\nagy="Linux Libertine O/B" at 12pt +\font\nagyss="Arial/B" at 12pt +\font\normal="Linux Biolinum O" at 8pt +\font\dolt="Linux Biolinum O/I" at 8pt +\normal + +EOF +'); + $ret = exec('cd '.$outputDir.'; cat '.$outputFile.'-u8.tex >> '.$outputFile.'.tex'); + $ret = exec('cd '.$outputDir.'; xetex -fmt '._MAYOR_DIR.'/print/module-naplo/xetex/mayor-xetex '.$outputFile.'.tex'); +#ex -fmt '._MAYOR_DIR.'/print/module-naplo/tex/mayor '.$outputFile.'.tex'); + } else { + // utf8 --> cork (t1) + $ret = exec('cd '.$outputDir.'; cat '.$outputFile.'-u8.tex | sed -e "s/\xc2\xa0/\x20/g" | recode u8..T1 > '.$outputFile.'.tex'); + // DVI, PS, PFD generálás (a rotate miatt nem megy a pdftex közvetlenül :o( + $ret = exec('cd '.$outputDir.'; tex -fmt '._MAYOR_DIR.'/print/module-naplo/tex/mayor '.$outputFile.'.tex'); + if ($ret === false) { $_SESSION['alert'][] = 'message:futási_hiba:generatePDF:tex'; return false; } +# LOG $ret = exec('cd '.$outputDir.'; dvips '.$outputFile.'.dvi 2>&1 | tee -a /tmp/x.log '); + $ret = exec('HOME=/tmp && export HOME && cd '.$outputDir.'; dvips '.$outputFile.'.dvi '); + if ($ret === false) { $_SESSION['alert'][] = 'message:futási_hiba:generatePDF:ps'; return false; } + $ret = exec('cd '.$outputDir.'; ps2pdf -sPAPERSIZE=a4 -dAutoRotatePages=/None '.$outputFile.'.ps'); + if (strpos($ret, 'error') !== false) { $_SESSION['alert'][] = 'message:futási_hiba:generatePDF:pdf'; return false; } + + } + if ($booklet) { + $ret = exec('cd '.$outputDir.'; mv '.$outputFile.'.pdf '.$outputFile.'-A4.pdf; pdfbook --short-edge --outfile '.$outputFile.'.pdf '.$outputFile.'-A4.pdf'); + } + return true; + } + + function generateXLS($fileName, $Table, $title) { + + global $policy, $page, $sub, $f; + + if (dirname($fileName) == '.') $fileName = _DOWNLOADDIR."/$policy/$page/$sub/$f/$fileName"; + $fp = fopen($fileName, 'w'); + if (!$fp) { + $_SESSION['alert'][] = 'message:file_open_failure:'.$fileName; + return false; + } + + fputs($fp, ''."\r\n"); + fputs($fp, ''."\r\n"); + fputs($fp, ' '."\r\n" + .' '."\r\n" + .' '."\r\n" + ."\r\n".' '."\r\n"); + + fputs($fp, ''."\r\n"); + fputs($fp, ''."\r\n"); + + for ($i = 0; $i < count($Table); $i++) { + fputs($fp, ' '."\r\n"); + foreach ($Table[$i] as $index => $value) { + if (is_numeric($value)) + fputs($fp, " ".$value."\r\n"); + elseif (strtotime($value)) + if (strlen($value) > 10) { + fputs($fp, " ".str_replace(' ','T',$value).'.000'."\r\n"); + } else { + fputs($fp, " ".$value.'T08:40:00.000'."\r\n"); + } + else + fputs($fp, " ".$value."\r\n"); + } + fputs($fp, ' '."\r\n"); + } + + fputs($fp, '
'."\r\n"); + fputs($fp, '
'."\r\n"); + fputs($fp, '
'."\r\n"); + + fclose($fp); + return true; + + } + + function generateCSV($fileName, $Table, $title, $mezoElvalaszto=' ') { + + global $policy, $page, $sub, $f; + + if (dirname($fileName) == '.') $fileName = _DOWNLOADDIR."/$policy/$page/$sub/$f/$fileName"; + $fp = fopen($fileName, 'w'); + if (!$fp) { + $_SESSION['alert'][] = 'message:file_open_failure:'.$fileName; + return false; + } + + if ($title !='') fputs($fp, $title."\n"); + for ($i = 0; $i < count($Table); $i++) fputs($fp, implode($mezoElvalaszto, $Table[$i])."\n"); + + fclose($fp); + return true; + + } + + function generateODS($fileName, $Table, $title) { + + global $policy, $page, $sub, $f; + + if (dirname($fileName) == '.') $fileName = _DOWNLOADDIR."/$policy/$page/$sub/$f/$fileName"; + define('TMPZIP','/tmp/'.substr(basename($fileName), 0, strpos(basename($fileName), '.'))); + define('ODS_MIMETIPE','application/vnd.oasis.opendocument.spreadsheet'); + define('ODS_MANIFEST',' + + + +'); + define('ODS_START_XMLDOCUMENT',' +'); + define('ODS_ASTYLES',' + + + - + + - + + + + '); + define('ODS_START_SPREADSHEET',''); + define('ODS_START_TABLE',''); + define('ODS_START_ROW',''); + define('ODS_END_ROW',''); + define('ODS_END_TABLE',''); + define('ODS_END_SPREADSHEET',''); + define('ODS_END_XMLDOCUMENT',''); + + $content = ODS_START_XMLDOCUMENT . ODS_ASTYLES . ODS_START_SPREADSHEET . ODS_START_TABLE; + for ($i = 0; $i < count($Table); $i++) { + $content .= ODS_START_ROW; + foreach ($Table[$i] as $index => $value) { + if (is_numeric($value)) + $content .= ''."\n"; + elseif (strtotime($value)) + if (strlen($value) > 10) { + $content .= ''."\n"; + } else { + $content .= ''."\n"; + } + elseif ($value[0] == '=') $content .= ''."\n"; + // formula példa: $value = 'of:=SUM([.A1:.B1])*2+[.A1]' + else $content .= ''.$value.''."\n"; + } + $content .= ODS_END_ROW; + } + $content .= ODS_END_TABLE . ODS_END_SPREADSHEET . ODS_END_XMLDOCUMENT; + + mkdir(TMPZIP); + mkdir(TMPZIP."/META-INF"); + file_put_contents(TMPZIP."/META-INF/manifest.xml", ODS_MANIFEST); + file_put_contents(TMPZIP."/content.xml", $content); + file_put_contents(TMPZIP."/mimetype", ODS_MIMETIPE); + system("cd ".TMPZIP."; zip -mr ".$fileName." mimetype META-INF/* content.xml >/dev/null"); + rmdir(TMPZIP."/META-INF"); + rmdir(TMPZIP); + + return true; + } + +/* --------------------------------------- */ + + function _template2array($fp, $type, &$aTeX) { + $vege = false; + $aTeX[$type] = array(); + while (!$vege && ($sor = fgets($fp, 1024))) { + $sor = chop($sor); + if ($sor == "%}$type") { + $vege = true; + } elseif (substr($sor, 0, 2) != '%!') { // A feldolgozást végző függvény megadása + if (substr($sor, 0, 2) == '%}') { + echo "HIBA #1 Megnyitás előtti blokk lezárás a {$type} blokkban: $sor
"; + } else { + if (substr($sor, 0, 2) == '%{') { + $_type = substr($sor, 2); + _template2array($fp, $_type, $aTeX); + $aTeX[$type][] = '%{'.$_type.'}'; + } else { + // feltételes szövegrészek + $condArray = explode('%?', $sor); + for ($i = 1; $i < count($condArray); $i = $i + 2) { + $str = $condArray[$i]; + $tmpArray = explode('|', $str); + $j = 0; while (is_array($aTeX['conditional']["$j".$tmpArray[0]])) $j++; + $newCondition = "$j".$tmpArray[0]; + $aTeX['conditional'][$newCondition] = array(true => $tmpArray[1], false => $tmpArray[2], 'orig' => $tmpArray[0]); + $sor = str_replace($str.'%?', $newCondition, $sor); + } +// $aTeX[$type][] = $sor; + // lezáró eset + $finalArray = explode('%>', $sor); + for ($i = 1; $i < count($finalArray); $i = $i + 2) { + $str = $finalArray[$i]; + $tmpArray = explode('', $str); + $j = 0; while (is_array($aTeX['finalCase']["$j".$type])) $j++; + $newCondition = "$j".$type; + $aTeX['finalCase'][$newCondition] = array(true => $tmpArray[0], false => $tmpArray[1]); + $sor = str_replace($str.'%>', $newCondition, $sor); + } + $aTeX[$type][] = $sor; + } + } + } + } + } + + function _array2text($type, $id, $mit, $mire, $aTeX, $ADAT, $flag = null) { + $ret = ''; + if (is_null($id)) $A = $ADAT[$type]; + else $A = $ADAT[$type][$id]; + + // A cserélendő attribútumok + if (is_array($A)) foreach ($A as $attr => $value) { + if (!is_array($value)) { + if (true || !is_bool($value)) { // feltételes szövegrészek külön kezelendők ??? Miért is? Az általánosabb feltételes kiíráshoz kell! + if (in_array('%$'.$attr, $mit)) { // A már szereplő mintát felülírjuk! + $key = array_search('%$'.$attr, $mit); + $mit[$key] = '%$'.$attr; + $mire[$key] = $value; + } else { + $mit[] = '%$'.$attr; + $mire[] = $value; + } + } + } + } + + // aTeX feldolgozása + $TeX = $aTeX[$type]; + for ($i = 0; $i < count($TeX); $i++) { + $sor = $TeX[$i]; + if (substr($sor, 0, 2) == '%{') { + // Almodul feldolgozása + $_type = substr($sor, 2, -1); + if (is_array($A[$_type])) { + if (is_null($id)) { + foreach ($A[$_type] as $key => $_id) $ret .= _array2text($_type, $_id, $mit, $mire, $aTeX, $ADAT); + } else { + $count = count($A[$_type]); $db = 0; + foreach ($A[$_type] as $_id => $_data) { + $db++; if ($count == $db) $_flag = 'final'; else $_flag = null; + if (!is_array($ADAT[$_type][$_id]) && !is_array($_data)) { + echo '
HIBA#2!!! '.$_type.':'.$_id.':'.$_data.'
'; +// return false; + } else { + if (!is_array($ADAT[$_type][$_id])) $ADAT[$_type][$_id] = array(); + elseif (!is_array($_data)) $_data = array(); + $ADAT[$_type][$_id] = $ADAT[$_type][$_id] + $_data; + $ret .= _array2text($_type, $_id, $mit, $mire, $aTeX, $ADAT, $_flag); + } + } + } + } elseif (__DEBUG === true) { echo '
HIBA#3: '.$sor.'
'.$_type.':'; var_dump($A[$_type]); echo '
';} + } else { + // Csere - lezáró eset + if (strpos($sor, '%>') !== false) foreach ($aTeX['finalCase'] as $attr => $values) { + $sor = str_replace('%>'.$attr, $values[ $flag === 'final' ], $sor); + } + // Csete - feltételes kiírás + if (strpos($sor, '%?') !== false) foreach ($aTeX['conditional'] as $attr => $values) { + // Nem csak az adott szintről veszi az értéket, hanem feljebbről is (a feljebbi a meghatározó - ez nem biztos, hogy jó...) + if ($key = array_search('%$'.$values['orig'], $mit)) $_val = $mire[$key]; + else $_val = $A[$values['orig']]; + $sor = str_replace('%?'.$attr, $values[ $_val==true ], $sor); + //$sor = str_replace('%?'.$attr, $values[ $A[$values['orig']]==true ], $sor); + } + // Kiírás + $ret .= str_replace($mit, $mire, $sor)."\n"; + } + } + + return $ret; + } + + function template2text($templateFile, $ADAT) { + + $mit = $mire = array(); + $aTeX = array('conditional' => array()); + + $fp = fopen($templateFile, 'r'); + _template2array($fp, 'base', $aTeX); + fclose($fp); + return _array2text('base', null, $mit, $mire, $aTeX, $ADAT); + + } + + function template2file($templateFile, $ADAT) { + + global $policy, $page, $sub, $f; + + $mit = $mire = array(); + $aTeX = array('conditional' => array()); + + $fp = fopen($templateFile, 'r'); + // A feldolgozást végző függvény neve + $sor = fgets($fp, 1024); + rewind($fp); + if (substr($sor, 0, 2) == '%!') { + list($func,$ext,$opt) = explode(' ', substr(chop($sor), 2)); + if (!function_exists($func)) unset($func); + } + if ($ext=='') $ext = 'txt'; + _template2array($fp, 'base', $aTeX); + fclose($fp); + $text = _array2text('base', null, $mit, $mire, $aTeX, $ADAT); +//die(); + if ($text === false) return false; + $success = true; + if (isset($func)) { + $success = $func($text, $ADAT['file'], $opt); + } else { + $fp = fopen(_DOWNLOADDIR."/$policy/$page/$sub/$f/".$ADAT['file'].'.'.$ext, 'w'); + fputs($fp, $text); + fclose($fp); + } + if ($success) return $ADAT['file'].".$ext"; + else return false; + + } + + + +?> diff --git a/mayor/bin/backup.sh b/mayor/bin/backup.sh deleted file mode 100644 index 152a9b7c..00000000 --- a/mayor/bin/backup.sh +++ /dev/null @@ -1,317 +0,0 @@ -#!/bin/bash - -OPT_SPEC="hnlf:d::" -LONG_OPT_SPEC="help,now,skip-lock,file:,backup-file:,dir:,backup-dir::" -PARSED_OPTIONS=$(getopt -n "$0" -a -o $OPT_SPEC --long $LONG_OPT_SPEC -- "$@") -OPTIONS_RET=$? -eval set -- "$PARSED_OPTIONS" - -help_usage() { -cat < $LOCKFILE -# echo -n " - Aktív munkamenetek törlése... " ### erre elvileg itt nincs szükség -# $MYSQL $MYSQL_PARAMETERS -e"DELETE FROM mayor_login.session" -# echo "kész." - else - if [ $VERBOSE -gt 1 ]; then echo -e "* A web-es elérés már le van tiltva..."; fi - LOCK_MARAD=1 - fi -else - if [ $VERBOSE -gt 1 ]; then echo -e "* A lock-olást a kérésedre kihagytam..."; fi -fi - -function freeup_lock { -if [ -e $LOCKFILE ]; then - if [ ! -z $LOCKFILE ] && [ $LOCK_MARAD != 1 ]; then - if [ $VERBOSE -gt 1 ]; then echo -e "-"; echo -n "* A web-es hozzáférés engedélyezése:..."; fi - rm $LOCKFILE - if [ $VERBOSE -gt 1 ]; then echo -e "kész."; echo -e "-"; fi - fi -fi -} - - -## -# A könyvtárak létrehozása -## - -if [ ! -e $BACKUPDIR ]; then - mkdir $BACKUPDIR > /dev/null 2>&1 - if [ $? -ne 1 ]; then - echo "*** Nem sikerült a $BACKUPDIR könyvtárat létrehozni!" - echo "**** MaYoR Backup failure! ****" - freeup_lock - exit 1 - fi -fi -chown $WEB_SERVER_USER $BACKUPDIR -chmod 700 $BACKUPDIR - -if [ -e $BACKUPDIR/$BACKUPFILE.tgz ]; then - echo -e "\n**** ERROR: már volt mentés: $BACKUPDIR/$BACKUPFILE.tgz ****\n" - freeup_lock - exit 1 -fi -mkdir $BACKUPDIR/$BACKUPFILE -chown $WEB_SERVER_USER $BACKUPDIR/$BACKUPFILE -chmod 700 $BACKUPDIR/$BACKUPFILE - -## -# mysql adatbázis mentése -## -if [ $VERBOSE -gt 0 ]; then - echo -e "-" - echo -e "* Backup fájl: $BACKUPFILE.tgz" -fi - -if [ "$MYSQL_HOST" == "" ]; then - MYSQL_HOST="localhost" -fi - -DB_INTEZMENYEK='' -if [ -f $MYSQL ] && [ -f $MYSQLDUMP ]; then - - if [ -f "$BASEDIR/config/my.cnf" ]; then - MYSQL_CONFIG="--defaults-extra-file=$BASEDIR/config/my.cnf" ##Vigyázat! a 'mysql' kliens rossz! Néha beleveszi a $(pwd) tartamát is! - TEST=$(echo "SHOW VARIABLES LIKE '%character_set_client%'" | $MYSQL "$MYSQL_CONFIG" | tail -n+2 | cut -f 2) -### Csak character_set_client=utf8 engedélyezett - if [ "$TEST" == "utf8" ]; then - if [ $VERBOSE -gt 2 ]; then echo -e "- MySQL-connect OK (my.cnf)" ; fi - else - MYSQL_CONFIG="-h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW --default-character-set=utf8" - fi - else - MYSQL_CONFIG="-h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW --default-character-set=utf8" - fi - -### Ellenőrizzük - TEST=$(echo "SHOW VARIABLES LIKE '%character_set_client%'" | $MYSQL $MYSQL_CONFIG | tail -n+2 | cut -f 2) - if [ "$TEST" == "utf8" ]; then - if [ $VERBOSE -gt 2 ]; then echo -e "- MySQL-connect OK (utf8+user/passw)"; fi - else - echo -e "*** MySQL-connect ERROR (nem utf8 vagy hibás user/passw)" - exit 2 - fi - - DATABASES='' - for DB in $(echo 'SHOW DATABASES' | $MYSQL $MYSQL_CONFIG); do - if [[ ! $EXCLUDED_DBS =~ .*$DB.* ]] && { [[ $DB =~ ^mayor.* ]] || [[ $DB =~ ^naplo.* ]] || [[ $DB =~ ^intezmeny.* ]]; } then - DATABASES="$DATABASES $DB" - fi - done - DB_INTEZMENYEK=$($MYSQL $MYSQL_CONFIG -e "SET NAMES 'utf8'; SELECT rovidNev FROM mayor_naplo.intezmeny; " | tail -n+2 ) ### Elvileg itt sem lehetne ékezetes - -else - echo -e "*** MySQL ERROR: A mysql kliens nem található: $MYSQL\n" - freeup_lock - exit 2 -fi - - -## -# Adatbázisok mentése -## - -if [ $VERBOSE -gt 2 ]; then echo -e "* Adatbázisok mentése:"; fi - -for DATABASE in $DATABASES; do - if [ ! -z $MYSQLDUMP ]; then - ### SET NAMES-hez: --set-charset - ### Szebb: --result-file=file_name -# mysqldump $MYSQL_CONFIG -R --set-charset --result-file="$BACKUPDIR/$BACKUPFILE/$DATABASE.sql" $DATABASE - $MYSQLDUMP $MYSQL_CONFIG -R --set-charset --result-file="$BACKUPDIR/$BACKUPFILE/$DATABASE.sql" $DATABASE - else - mysqldump $MYSQL_CONFIG -R --set-charset --result-file="$BACKUPDIR/$BACKUPFILE/$DATABASE.sql" $DATABASE - fi - if [ $VERBOSE -gt 3 ]; then echo -e "- $DATABASE"; fi -done - - -## -# A honlap mentése -## -if [ $VERBOSE -gt 2 ]; then echo -e "* Fájlok mentése:"; fi -mkdir $BACKUPDIR/$BACKUPFILE/log -cp -a $BASEDIR/log/revision $BACKUPDIR/$BACKUPFILE/log/revision -if [ $VERBOSE -gt 3 ]; then echo -e "- revision"; fi -cp -a $BASEDIR/www $BACKUPDIR/$BACKUPFILE/www -if [ $VERBOSE -gt 3 ]; then echo -e "- www/*"; fi -cp -a $BASEDIR/config $BACKUPDIR/$BACKUPFILE/config -if [ $VERBOSE -gt 3 ]; then echo -e "- config/*"; fi - -if [ $VERBOSE -gt 2 ]; then echo -e "* Templétek mentése:"; fi -for RN in $(echo $DB_INTEZMENYEK); do ## a nyomtatási templétek is legyenek benne a mentésben -if [ -d "$BASEDIR/print/module-naplo/templates/$RN" ]; then - mkdir -p $BACKUPDIR/$BACKUPFILE/print/module-naplo/templates/ - cp -a $BASEDIR/print/module-naplo/templates/$RN $BACKUPDIR/$BACKUPFILE/print/module-naplo/templates/$RN - if [ $VERBOSE -gt 3 ]; then echo -e "- $RN/*"; fi -fi -done - -if [ "$SAVELDAP" == 1 ]; then - - ## - # Az LDAP adatbázis - ## - if [ $VERBOSE -gt 1 ]; then echo -e "* LDAP mentése"; fi - - /etc/init.d/slapd stop - sleep 1 - - slapcat -b $BASEDN -l $BACKUPDIR/$BACKUPFILE/ldap.ldif - - cp -a $LDAPDBDIR $BACKUPDIR/$BACKUPFILE/ldap - - /etc/init.d/slapd start - - ## - # LDAP konfig file-ok mentése (schema) - ## - - mkdir $BACKUPDIR/$BACKUPFILE/etc - cp -a $LDAPCONFDIR $BACKUPDIR/$BACKUPFILE/etc/ - -fi - -## -# Becsomagolás -## - -if [ $VERBOSE -gt 2 ]; then echo -e "* Becsaomagolás"; fi -cd $BACKUPDIR -#### Ez a korábbi szerintem hibás: -#### tar cfz ${BACKUPFILE}.tgz ${DATE} -#tar cfz ${BACKUPFILE}.tgz ${BACKUPFILE} ##Ez is néha... - -# ez már jó -tar -czf "$BACKUPFILE.tgz" "$BACKUPFILE/" -rm -rf $BACKUPFILE -#Debian6 inkompatibilis: tar cfz ${BACKUPFILE}.tgz --remove-files ${BACKUPFILE} - -if [ $VERBOSE -gt 0 ]; then echo -e "* Takarítás"; fi -## -# Mentés átmásolása másik szerverre -# rsync # Losonci János kiegészítése (losy@agymk.sulinet.hu) -## - -if [ "$RSYNC" == 1 ]; then - if [ $VERBOSE -gt 2 ]; then echo -e "* RSYNC küldés"; fi - RSYNCBIN=$(which rsync) - if [ "$RSYNCBIN" != "" ]; then - echo $RSYNCBIN -auvE $BACKUPDIR/ $RUSER@$RHOST:$RPATH/ - $RSYNCBIN -auvE $BACKUPDIR/ $RUSER@$RHOST:$RPATH/ - if [ $? -ne 0 ]; then - echo "rsync error!" - fi - fi -fi - -## -# Elavult mentés törlése -## - -declare -i BDAYS=BACKUPDAYS -if [ $BDAYS -gt 0 ]; then - find $BACKUPDIR -mtime +$BDAYS -exec rm {} \; -fi - -### -## Végül a lock-olás feloldása -# -freeup_lock -if [ $VERBOSE -gt 1 ]; then echo -e "* Backup-script vége.\n"; fi - -### \ No newline at end of file diff --git a/mayor/bin/crypt-backup.sh b/mayor/bin/crypt-backup.sh deleted file mode 100644 index 11e10a27..00000000 --- a/mayor/bin/crypt-backup.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/bash -# -# Example: mayor crypt-backup --backup-file=/tmp/wiki.tgz -# Az eredmény a $BACKUPDIR/$DATE-crypt.tgz állományba kerül -# (Vagy jobb lenne, ha a file nevéből venné a nevét?) -# -# TODO: ellenőrizni kell még, hogy van-e openssl és aespipe -# - -OPT_SPEC="hf:d::" -LONG_OPT_SPEC="help,file:,backup-file:,dir:,backup-dir::" -PARSED_OPTIONS=$(getopt -n "$0" -a -o $OPT_SPEC --long $LONG_OPT_SPEC -- "$@") -OPTIONS_RET=$? -eval set -- "$PARSED_OPTIONS" - -help_usage() { -cat < /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "Nem sikerült a ${BACKUPDIR} könyvtárat létrehozni!" - echo "MaYoR Backup failure!" - exit 3 - fi -fi -CRYPTDIR=$BACKUPDIR/$DATE -if [ ! -e $CRYPTDIR ]; then - mkdir $CRYPTDIR -fi -chown $WEB_SERVER_USER $BACKUPDIR -chmod 700 $BACKUPDIR - -if [ ! -f $BACKUPFILE ]; then - # Próbáljuk meg a mai dátum szerinti backup-ot (alapértelmezés) - echo -e " HIBA: Hiányzik a kódolandó mentési állomámny: (${BACKUPFILE})\n" - BACKUPFILE=$BACKUPDIR/${BACKUPFILE} - echo "Próbáljuk a mentéi könyvtáron belül: ${BACKUPFILE}" - if [ ! -f $BACKUPFILE ]; then - echo -e " HIBA: Hiányzik a kódolandó mentési állomámny: (${BACKUPFILE})\n" - BACKUPFILE=$BACKUPDIR/${PREFIX}${DATE}.tgz - echo "Próbáljuk az alapértelmezett állománynevet: ${BACKUPFILE}" - if [ ! -e $BACKUPFILE ]; then - echo -e " HIBA: Hiányzik a kódolandó mentési állomámny: (${BACKUPFILE})\n" - exit 3 - fi - fi -fi -BASENAME=`basename $BACKUPFILE` - -# Publikus kulcs lekérdezése -echo 'SELECT publicKey FROM mayorSsl' | $MYSQL -p$PW -u$USER $DB | grep -v publicKey | sed -e 's/\\n/\n/g' > $CRYPTDIR/id_rsa.pub - -# Véletlen kulcs generálás a szimmetrikus AES kódoláshoz -pwgen -nc 50 1 > $CRYPTDIR/key.txt - -# AES kódolás -aespipe -P $CRYPTDIR/key.txt -e aes256 < $BACKUPFILE > $CRYPTDIR/$BASENAME.aes - -# A kulcsok RSA kódolása a publikus kulccsal -openssl rsautl -encrypt -inkey $CRYPTDIR/id_rsa.pub -pubin -in $CRYPTDIR/key.txt -out $CRYPTDIR/key.rsa - -# Kulcsok törlése -rm $CRYPTDIR/id_rsa.pub -rm $CRYPTDIR/key.txt - -cd $BACKUPDIR -tar cfz ${DATE}-crypt.tgz ${DATE} -rm -rf $DATE - -echo -e "\nBecsomagolva: $BACKUPDIR/${DATE}-crypt.tgz\n\n" diff --git a/mayor/bin/decrypt-backup.sh b/mayor/bin/decrypt-backup.sh deleted file mode 100644 index 9eca4375..00000000 --- a/mayor/bin/decrypt-backup.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash -# -# Example: mayor decrypt-backup --crypted-file=/home/backup/20110515-crypt.tgz -# Az eredmény a $BACKUPDIR alá kerül az eredetileg elkódolt állomány nevéből -# származtatott néven: file.kit --> file-decrypt.kit -# -# TODO: ellenőrizni kell még az openssl és az aespipe meglétét -# - -OPT_SPEC="hf:d::" -LONG_OPT_SPEC="help,file:,crypted-file:,dir:,backup-dir::" -PARSED_OPTIONS=$(getopt -n "$0" -a -o $OPT_SPEC --long $LONG_OPT_SPEC -- "$@") -OPTIONS_RET=$? -eval set -- "$PARSED_OPTIONS" - -help_usage() { -cat < /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "Nem sikerült a ${BACKUPDIR} könyvtárat létrehozni!" - echo "MaYoR Backup failure!" - exit 3 - fi -fi -chown $WEB_SERVER_USER $BACKUPDIR -chmod 700 $BACKUPDIR - -# bejövő paraméterek feldolgozása (crypted-file) -if [ ! -f $FILE ]; then - echo -e " HIBA: Hiányzik a dekódolandó mentési állomámny: ${FILE}\n" - FILE=$BACKUPDIR/${FILE} - echo "Próbáljuk a mentési könyvtárban (${FILE})" - if [ ! -f $FILE ]; then - echo -e " HIBA: Hiányzik a dekódolandó mentési állomámny: ${FILE}\n" - FILE=$BACKUPDIR/${PREFIX}${DATE}-crypt.tgz - echo "Próbáljuk az alapértelmezett állományt (${FILE})" - if [ ! -e $FILE ]; then - echo " HIBA: Hiányzik a dekódolandó mentési állomámny: ${FILE}" - exit 4 - fi - fi -fi -BASENAME=`basename $FILE` - -cd $BACKUPDIR -tar xfz $FILE -TARFILES=`tar tf $FILE` -SUBDIR=`for f in $TARFILES; do echo $f; break; done` -AESFILE=`echo $TARFILES | sed -e 's/ /\n/g' | grep '.aes'` -AESBASE=`basename $AESFILE | sed -e 's/.aes//g'` -DECRYPTFILE=`echo $AESBASE | sed -e 's/\.\([a-z]*\)$/-decrypt\.\1/'` - -# A privát kulcs lekérdezése -echo 'SELECT privateKey FROM mayorSsl' | $MYSQL -p$PW -u$USER $DB | grep -v privateKey | sed -e 's/\\n/\n/g' > $BACKUPDIR/$SUBDIR/id_rsa - -# AES kulcs dekódolása -openssl rsautl -decrypt -inkey $BACKUPDIR/$SUBDIR/id_rsa -in $BACKUPDIR/$SUBDIR/key.rsa -out $BACKUPDIR/$SUBDIR/key.txt - -# AES dekódolás (feltételezzük, hogy az eredmény tgz -aespipe -P $BACKUPDIR/$SUBDIR/key.txt -d -e aes256 < $BACKUPDIR/$AESFILE > $BACKUPDIR/$DECRYPTFILE - -# Törlés -rm -rf $BACKUPDIR/$SUBDIR - -echo -e "\nKicsomagolva: $BACKUPDIR/$DECRYPTFILE\n\n" diff --git a/mayor/bin/etc/cron.daily/mayor b/mayor/bin/etc/cron.daily/mayor deleted file mode 100755 index 815cc023..00000000 --- a/mayor/bin/etc/cron.daily/mayor +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# A helyes környezet beállítása (svn alapú frissítés esetén az ékezetes file-nevekhez) -export LANG=hu_HU.UTF-8 - -# Napló napi mentése -/usr/local/sbin/mayor backup - -# Heti frissítés -if [ `date +'%w'` == 0 ]; then - /usr/local/sbin/mayor update -fi - diff --git a/mayor/bin/help.sh b/mayor/bin/help.sh deleted file mode 100644 index e983ccd3..00000000 --- a/mayor/bin/help.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -OPT_SPEC="hf::" -LONG_OPT_SPEC="help,file:,f::" -PARSED_OPTIONS=$(getopt -n "$0" -a -o $OPT_SPEC --long $LONG_OPT_SPEC -- "$@") -OPTIONS_RET=$? -eval set -- "$PARSED_OPTIONS" - -help_usage() { - print_help; - echo -e "\nHELP használata: mayor help [parancs]\n\n" -} - -if [ $OPTIONS_RET -ne 0 ] || [ $# -le 1 ]; then help_usage; exit; fi - -while [ $# -ge 1 ]; do - case $1 in - --help | -h ) help_usage - exit - ;; - - --file | -f ) shift - FILE="$1" - echo "FILE: $FILE" - ;; - - -- ) shift - break - ;; - - * ) echo "HIBA: ismeretlen opció: $1" # ide elvileg sose jutunk, mert a getopts már kiszűrte a hibás paramétereket... - exit - ;; - esac - shift -done - -while [ $# -ge 1 ]; do - echo -e "\n---------- HELP: $1 ----------\n" - if [[ ! "${CMDS[*]}" =~ .*$1.* ]]; then - echo -e "Ismeretlen parancs: $1" - #print_help - else - . ./$1.sh --help - fi - shift -done diff --git a/mayor/bin/lock.sh b/mayor/bin/lock.sh deleted file mode 100644 index ca275705..00000000 --- a/mayor/bin/lock.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -help_usage() { -cat < $LOCKFILE - if [ $VERBOSE -gt 0 ]; then echo -e "kész.\n"; fi -fi - diff --git a/mayor/bin/mayor b/mayor/bin/mayor deleted file mode 100755 index 09168cc0..00000000 --- a/mayor/bin/mayor +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash - -VERSION="2.0" -echo -e "\nmayor szkript - verzió: $VERSION (" $(date '+%Y-%m-%d') ")" - -CMDS=(backup update lock unlock crypt-backup decrypt-backup remote-backup restore help) -MODS=(mayor-base mayor-portal mayor-naplo mayor-naplo-sni mayor-wiki mayor-felveteli mayor-installer mayor-installer-sulix mayor-jatek mayor-locales-de_DE mayor-locales-en_US mayor-local-jp_JP) -DESC=('a rendszer mentése' 'a rendszer frissítése' 'a rendszer zárolása (lockfile)' 'a rendszer feloldása' 'a mentés titkosítása (ß)' 'a titkosított mentés visszakódolása (ß)' 'mentés a központi (távoli) szerverre' 'mentés visszatöltése' 'A parancs működésének leírása') -#OPTS=('--skip-lock') -#OPTDESC=('a rendszer zárolásának kihagyása') -DATE=$(date "+%Y%m%d") -DATETIME=$(date "+%Y-%m-%d %H:%M:%S") - -print_help() { - echo -e "\nHasználat: mayor [parancs] [opciók]\n\nParancs" - for ((i=0; i<${#CMDS[@]}; i=i+1)); do - len=$(echo ${CMDS[$i]} | wc -m) - if [ "$len" -lt 13 ]; then - echo -e " - ${CMDS[$i]}:\t\t${DESC[$i]}" - else - echo -e " - ${CMDS[$i]}:\t${DESC[$i]}" - fi - done -# echo -e "\nOpciók" -# for ((i=0; i<${#OPTS[@]}; i=i+1)); do -# echo " ${OPTS[$i]}: ${OPTDESC[$i]}" -# done - echo "" -} - -# Ellenőrizzük, hogy van-e configurációs állomány -if [ -f /etc/mayor/main.conf ]; then - . /etc/mayor/main.conf -else - echo -e "\n*** HIBA: hiányzó konfigurációs file: /etc/mayor/main.conf\n" - exit 1 -fi - -# Ha nincs paraméter, akkor írjuk ki a tennivalót -if [ -z $1 ]; then - print_help - exit 1 -fi - -# A paraméter ellenőrzése -for ((i=0; i<${#CMDS[@]}; i=i+1)); do - if [ ${CMDS[$i]} == "$1" ]; then - CMD=${CMDS[$i]} - break - fi -done - -if [ -z $CMD ]; then - echo -e "\n(>>> HIBA: ismeretlen parancs: $1)\n" - print_help - exit 1 -else - echo -e "(>>> $CMD)\n" -fi - -# Alapértelmezés -if [ "$MYSQL_HOST" == "" ]; then - MYSQL_HOST="localhost" -fi - -shift -# A parancs végrehajtása -cd $BASEDIR/bin -if [ -z $UPDATELOG ]; then - . ./$CMD.sh -else - . ./$CMD.sh 2>&1 | tee -a $UPDATELOG -fi - diff --git a/mayor/bin/remote-backup.sh b/mayor/bin/remote-backup.sh deleted file mode 100644 index 71e241d5..00000000 --- a/mayor/bin/remote-backup.sh +++ /dev/null @@ -1,170 +0,0 @@ -#!/bin/bash -# -# Example: mayor remote-backup --backup-file=/tmp/wiki.tgz -# Az eredmény a $BACKUPDIR/$DATE-crypt.tgz állományba kerül -# (Vagy jobb lenne, ha a file nevéből venné a nevét?) -# -# TODO: ellenőrizni kell még, hogy van-e openssl és aespipe -# - -OPT_SPEC="hf:d::" -LONG_OPT_SPEC="help,file:,backup-file:,dir:,backup-dir::" -PARSED_OPTIONS=$(getopt -n "$0" -a -o $OPT_SPEC --long $LONG_OPT_SPEC -- "$@") -OPTIONS_RET=$? -eval set -- "$PARSED_OPTIONS" - -help_usage() { -cat < /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "Nem sikerült a ${BACKUPDIR} könyvtárat létrehozni!" - echo "MaYoR Backup failure!" - exit 3 - fi -fi -CRYPTDIR=$BACKUPDIR/$DATE -if [ ! -e $CRYPTDIR ]; then - mkdir $CRYPTDIR -fi -chown $WEB_SERVER_USER $BACKUPDIR -chmod 700 $BACKUPDIR - -if [ ! -f $FILE ]; then - echo -e " HIBA: Hiányzik a kódolandó mentési állomámny: ${FILE}" - FILE=$BACKUPDIR/${FILE} - echo "Próbáljuk a mentési könyvtárban! (${FILE})" - if [ ! -f $FILE ]; then - echo -e " HIBA: Hiányzik a kódolandó mentési állomámny: ${FILE}" - FILE=$BACKUPDIR/${PREFIX}${DATE}.tgz - echo "Próbáljuk az alapértelmezett állományt! (${FILE})" - if [ ! -e $FILE ]; then - echo -e " HIBA: Hiányzik a kódolandó mentési állomámny: ${FILE}" - exit 3 - fi - fi -fi -BASENAME=`basename $FILE` - -# Publikus kulcs lekérdezése -echo 'SELECT publicKey FROM mayorSsl' | $MYSQL -p$PW -u$USER $DB | grep -v publicKey | sed -e 's/\\n/\n/g' > $CRYPTDIR/id_rsa.pub - -# Véletlen kulcs generálás a szimmetrikus AES kódoláshoz -pwgen -nc 50 1 > $CRYPTDIR/key.txt - -# AES kódolás -aespipe -P $CRYPTDIR/key.txt -e aes256 < $FILE > $CRYPTDIR/$BASENAME.aes - -# A kulcsok RSA kódolása a publikus kulccsal -openssl rsautl -encrypt -inkey $CRYPTDIR/id_rsa.pub -pubin -in $CRYPTDIR/key.txt -out $CRYPTDIR/key.rsa - -# Kulcsok törlése -rm $CRYPTDIR/id_rsa.pub -rm $CRYPTDIR/key.txt - -cd $BACKUPDIR -tar cfz ${DATE}-crypt.tgz ${DATE} -rm -rf $DATE - -echo -e "\nBecsomagolva: $BACKUPDIR/${DATE}-crypt.tgz\n\n" - -# A privát kulcs lekérdezése, elhelyezése -if [ ! -d $BASEDIR/ssh ]; then - echo "Létrehozzuk a $BASEDIR/ssh könyvtárat, amibe belerakjuk a privát kulcsot..." - mkdir $BASEDIR/ssh - chmod 700 $BASEDIR/ssh -fi -if [ ! -f $BASEDIR/ssh/id_rsa ]; then - echo 'SELECT privateKey FROM mayorSsl' | $MYSQL -p$PW -u$USER $DB | grep -v privateKey | sed -e 's/\\n/\n/g' > $BASEDIR/ssh/id_rsa - chmod 700 $BASEDIR/ssh/id_rsa -fi - -# Az intézmény OM kódjának lekérdezése - -# A mayor_naplo adatbázis eléréséhez szükséges paraméterek lekérdezése a konfig-ból... -DB=`grep db $BASEDIR/config/module-naplo/config.php | sed -e "s/$.*=\ *['|\"]//g" -e "s/['|\"];//g"` -USER=`grep userRead $BASEDIR/config/module-naplo/config.php | sed -e "s/$.*=\ *['|\"]//g" -e "s/['|\"];//g" | sed 's/^ *//g'` -PW=`grep pwRead $BASEDIR/config/module-naplo/config.php | sed -e "s/$.*=\ *['|\"]//g" -e "s/['|\"];//g" | sed 's/^ *//g'` - -OMKOD=`echo 'SELECT SUBSTR(OMKod,-6) FROM intezmeny WHERE alapertelmezett = 1' | $MYSQL -p$PW -u$USER $DB | grep -v OMKod` -SSH_USER="om$OMKOD" -echo $SSH_USER - -# A kódolt adatállomány másolása -scp -i $BASEDIR/ssh/id_rsa -P $SSH_PORT $BACKUPDIR/${DATE}-crypt.tgz $SSH_USER@$SSH_HOST:/home/$SSH_USER/ diff --git a/mayor/bin/restore.sh b/mayor/bin/restore.sh deleted file mode 100644 index 7a1195ed..00000000 --- a/mayor/bin/restore.sh +++ /dev/null @@ -1,257 +0,0 @@ -#!/bin/bash - -OPT_SPEC="hkprf:d:t::" -LONG_OPT_SPEC="help,keep-old-passwords,restore-parent,restore-private,tmp-dir:,file:,backup-file:,dir:,base-dir::" -PARSED_OPTIONS=$(getopt -n "$0" -a -o $OPT_SPEC --long $LONG_OPT_SPEC -- "$@") -OPTIONS_RET=$? -eval set -- "$PARSED_OPTIONS" - -help_usage() { -cat </dev/null; then - echo "ok." - else - echo "hiba." - exit 3 - fi -fi - -if [ ! -d "${RTMPDIR}/restore" ]; then - if ! mkdir "${RTMPDIR}/restore" 2>/dev/null; then - echo "Hiba: Az ideiglenes könyvtár nem írható (${RTMPDIR})!" - exit 4 - fi -fi -chmod 700 "${RTMPDIR}/restore" -cd "${RTMPDIR}/restore" -tar xvfz $RBACKUPFILE -DT=$(ls) -echo "A mentés dátuma: ${DT}" -cd ${DT} - -RREVISIONFILE="${RTMPDIR}/restore/${DT}/log/revision" -declare -i BAK_REV -if [ ! -e "${RREVISIONFILE}" ]; then - echo "Hiba: A mentési állomány nem tartalmaz verzió információt!" - echo -e " A mentési állományon belül, a ${DT}/log/revision állományba írja be a revision számot (pl: 2512)!\n" - cleartmp - exit 5 -fi -BAK_REV=$(cat $RREVISIONFILE) -echo "A mentett rendszer revision száma: ${BAK_REV}" - -if [ ${BAK_REV} -gt ${INST_REV} ]; then - echo "Hiba: A mentett rendszer újabb, mint a telepített!" - echo -e " A telepített rendszer revision száma nagyobb vagy egyenlő kell legyen a mentett rendszer revision számánál!\n Telepítsen frissíebb rendszert!\n" - cleartmp - exit 6 -fi - -# A telepített rendszer beállításainsak betöltése -if [ -f "${RBASEDIR}/config/main.conf" ]; then - . "${RBASEDIR}/config/main.conf" -else - echo "Hiba: A telepített rendszer nincs beállítva!" - echo -e " Hiányzik a konfigurációs állomány: ${RBASEDIR}/config/main.conf\n" - cleartmp - exit 7 -fi - -# Az adatbázisok betöltése -NAPLOUSER=$(egrep 'userWrite.*=' $BASEDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -NAPLOUSERREAD=$(egrep 'userRead.*=' $BASEDIR/config/module-naplo/config.php | sed -e "s/^.*=\ *['|\"]//g" -e "s/['|\"];//g") -DBS=$($MYSQL -h$MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PW -e"SHOW DATABASES") -if [ "$RESTORE_PARENT" == "1" ]; then - FILES="mayor_naplo.sql mayor_parent.sql intezmeny_*.sql naplo_*.sql" -else - FILES="mayor_naplo.sql intezmeny_*.sql naplo_*.sql" -fi -if [ "$RESTORE_PRIVATE" == "1" ]; then - FILES="$FILES mayor_private.sql" -fi -for SQLFILE in $FILES; do - if [ -e "${SQLFILE}" ]; then - DB=${SQLFILE%.sql} - echo -n "${DB} ... " - if [[ ! ${DBS} =~ .*$DB.* ]]; then - echo -n "... " - (cat < ${iNCDIR}/config.php.backup" - mv "${iNCDIR}/config.php" "${iNCDIR}/config.php.backup" - fi -fi - -cat "${bNCDIR}/config.php" | sed \ - -e "s/db\(.*\)$bDB\(.*\)/db\1$iDB\2/g" \ - -e "s/userWrite\(.*\)$bUSER\(.*\)/userWrite\1$iUSER\2/g" \ - -e "s/userRead\(.*\)$bUSERREAD\(.*\)/userRead\1$iUSERREAD\2/g" \ - -e "s/$bPW/$iPW/g" -e "s/$bPWREAD/$iPWREAD/g" > "${iNCDIR}/config.php" - -for FILE in config-*.php; do - echo -n "$FILE ... " - # mentés - if [ -e "${iNCDIR}/$FILE" ]; then - if [ ! -e "${iNCDIR}/$FILE.backup" ]; then - echo -n "... " - mv "${iNCDIR}/$FILE" "${iNCDIR}/$FILE.backup" - fi - fi - cp $FILE "${iNCDIR}/$FILE" - echo ok -done - -cd ${BASEDIR}/bin -if [ -z $UPDATELOG ]; then - . update.sh -e -r$BAK_REV -b${BASEDIR} -else - . update.sh -e -r$BAK_REV -b${BASEDIR} 2>&1 | tee -a $UPDATELOG -fi - -# Az ideiglenes könyvtár törlése -cleartmp - diff --git a/mayor/bin/sbin/eNaploBackup.sh b/mayor/bin/sbin/eNaploBackup.sh deleted file mode 100755 index 5bdba177..00000000 --- a/mayor/bin/sbin/eNaploBackup.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/sh -## -# Az elektronikus mentése (Version 1.0) -## - - DATE=`date +%Y%m%d` - NAPLO_BACKUP_BASE_DIR='/backup/naplo' - NAPLO_BACKUP_DIR="$NAPLO_BACKUP_BASE_DIR/$DATE" - - DATABASES='mayor_parent mayor_private mayor_naplo intezmeny_fasori naplo_fasori_2007' - #MYSQL_DB='%MYSQL_NAPLO_DB%' - MYSQL_USER='%MYSQL_NAPLO_USER%' - MYSQL_PW='%MYSQL_NAPLO_PW%' - - WWW_SSL_DIR='%BASEDIR%' - WEB_SERVER_USER='%WEB_SERVER_USER%' - EXPIRE_DATE=`date -d '30 days ago' +%Y%m%d` - - BASEDN='%BASEDN%' - LDAP_CONF_DIR='%LDAP_CONF_DIR%' - LDAP_DB_DIR='%LDAP_DB_DIR%' - -## -# A könyvtárak létrehozása -## - if [ ! -e $NAPLO_BACKUP_BASE_DIR ]; then - /bin/mkdir $NAPLO_BACKUP_BASE_DIR - fi - /bin/chown $WEB_SERVER_USER $NAPLO_BACKUP_BASE_DIR - /bin/chmod 700 $NAPLO_BACKUP_BASE_DIR - - if [ -e $NAPLO_BACKUP_DIR.tgz ]; then - exit 1 - fi - /bin/mkdir $NAPLO_BACKUP_DIR - /bin/chown $WEB_SERVER_USER $NAPLO_BACKUP_DIR - /bin/chmod 700 $NAPLO_BACKUP_DIR - -## -# mysql adatbázis mentése -## - -for DATABASE in $DATABASES; do - /usr/bin/mysqldump -p$MYSQL_PW -u$MYSQL_USER $DATABASE >> $NAPLO_BACKUP_DIR/$DATABASE.sql -done - -## -# mysql adatbázis mentése -## - -# /usr/bin/mysqldump -p$MYSQL_PW -u$MYSQL_USER $MYSQL_DB >> $NAPLO_BACKUP_DIR/$MYSQL_DB.sql - -## -# A honlap mentése -## - - mkdir $NAPLO_BACKUP_DIR/html - - /bin/cp -a $WWW_SSL_DIR/* $NAPLO_BACKUP_DIR/html/ - -## -# Az LDAP adatbázis -## - - /etc/init.d/slapd stop - /bin/sleep 1 - - /usr/sbin/slapcat -b $BASEDN -l $NAPLO_BACKUP_DIR/ldap.ldif - - /bin/cp -a $LDAP_DB_DIR $NAPLO_BACKUP_DIR/ldap - - /etc/init.d/slapd start - -## -# LDAP konfig file-ok mentése (schema) -## - - /bin/mkdir $NAPLO_BACKUP_DIR/etc - /bin/cp -a $LDAP_CONF_DIR $NAPLO_BACKUP_DIR/etc/ - -## -# Becsomagolás -## - - cd $NAPLO_BACKUP_BASE_DIR - /bin/tar cfz $DATE.tgz $DATE - /bin/rm -rf $NAPLO_BACKUP_DIR - -## -# Elavult mentés tölése -## - - if [ -e $NAPLO_BACKUP_BASE_DIR/$EXPIRE_DATE.tgz ]; then - rm -rf $NAPLO_BACKUP_BASE_DIR/$EXPIRE_DATE.tgz - fi diff --git a/mayor/bin/sbin/eNaploRestore.sh b/mayor/bin/sbin/eNaploRestore.sh deleted file mode 100755 index f383360f..00000000 --- a/mayor/bin/sbin/eNaploRestore.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh -## -# Az elektronikus visszatöltése (Version 1.0) -## - - NAPLO_BACKUP_BASE_DIR='/backup/naplo' - NAPLO_BACKUP_TMP_DIR="$NAPLO_BACKUP_BASE_DIR/tmp" - - DATABASE='%MYSQL_NAPLO_DB%' - MYSQL_PW='%MYSQL_ROOT_PW%' - MYSQL_USER='root' - - WWW_DIR='%BASEDIR%' - WEB_SERVER_USER='%WEB_SERVER_USER%' - BASEDN='%BASEDN%' - DUMP_FILE="$DATABASE.sql" - LDIF_FILE='ldap.ldif' - LDAP_DB_DIR='%LDAP_DB_DIR%/mayor' - -## -# A paraméter ellenőrzése -## - - if [ -z $1 ]; then - exit 1 - else - if [ -e $NAPLO_BACKUP_BASE_DIR/$1 ]; then - FILE=$1 - DATE=`echo $FILE | cut -d . -f 1` - else - exit 2 - fi - fi - -echo "PARAMÉTER: $1" - -## -# TMP Könyvtár ellenőrzése, létrehozása -## - - if [ ! -e $NAPLO_BACKUP_TMP_DIR ]; then - /bin/mkdir $NAPLO_BACKUP_TMP_DIR - fi - /bin/chown $WEB_SERVER_USER $NAPLO_BACKUP_TMP_DIR - /bin/chmod 700 $NAPLO_BACKUP_TMP_DIR - -## -# Adatfile kicsomagolása -## - - cd $NAPLO_BACKUP_TMP_DIR - /bin/tar xfz $NAPLO_BACKUP_BASE_DIR/$FILE - if [ ! -e $NAPLO_BACKUP_TMP_DIR/$DATE/$DUMP_FILE ]; then - exit 3 - fi - if [ ! -e $NAPLO_BACKUP_TMP_DIR/$DATE/$LDIF_FILE ]; then - exit 4 - fi - -## -# Az LDAP adatbázis visszatöltése/felülírása -## - - /etc/init.d/slapd stop - /bin/sleep 1 - - /bin/rm -rf $LDAP_DB_DIR/* - /usr/sbin/slapadd -c -b $BASEDN -l $NAPLO_BACKUP_TMP_DIR/$DATE/$LDIF_FILE - - /etc/init.d/slapd start - -## -# mysql adatbázis visszatöltése -## - -(cat < $REV - -for f in $PARENT; do - ln -s $DIR/www/policy/private/naplo/$f-pre.php $DIR/www/policy/parent/naplo/$f-pre.php - ln -s $DIR/www/policy/private/naplo/$f.php $DIR/www/policy/parent/naplo/$f.php -done - -for f in $PUBLIC; do - ln -s $DIR/www/policy/private/naplo/$f-pre.php $DIR/www/policy/public/naplo/$f-pre.php - ln -s $DIR/www/policy/private/naplo/$f.php $DIR/www/policy/public/naplo/$f.php -done - -for f in $WRITABLE; do - chmod a+rwx $DIR/$f -done diff --git a/mayor/bin/tex2pdf.sh b/mayor/bin/tex2pdf.sh deleted file mode 100644 index ee177b11..00000000 --- a/mayor/bin/tex2pdf.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# A script segítségével tesztelhetjük, hogy mi történik, mikor a program a haladásinaplót, illetve osztályozónaplót generálja... -# -# Paraméter: a feldolgozandó UTF-8 kódolású TeX állomány "-u8.tex" végződés nélküli neve. -# - -. /etc/mayor/main.conf - -HOME="/tmp" -export HOME - -# Make sure this exists -# cd $BASEDIR/print/module-naplo/tex/ -# fmtutil-sys --cnffile $BASEDIR/print/module-naplo/tex/mayor.cnf --fmtdir $BASEDIR/print/module-naplo/ --byfmt mayor - -cat $1-u8.tex | recode u8..T1 > $1.tex - -tex -fmt $BASEDIR/print/module-naplo/tex/mayor $1.tex - -dvips $1.dvi - -ps2pdf -sPAPERSIZE=a4 -dAutoRotatePages=/None $1.ps - diff --git a/mayor/bin/unlock.sh b/mayor/bin/unlock.sh deleted file mode 100644 index 98783f4b..00000000 --- a/mayor/bin/unlock.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -help_usage() { -cat < /dev/null - for MODULE in $MODULES; do - echo -n " $MODULE... " - chmod +x $BASEDIR/bin/mayor - if [ $? != 0 ]; then exit 2; fi - UJ_REV=$($SVN --force export https://svn.mayor.hu/svn/trunk/$MODULE/update "$BASEDIR/update" | grep revision | cut -d ' ' -f 3 | uniq | sed -e 's/\.//g') - if [ $? != 0 ]; then exit 3; fi - echo "kész." - done - else - echo -e "\n\nERROR: A subversion kliens nem található: $SVN" - exit 4 - fi - else - # Munkakönyvtár létrehozása - if [ ! -d $TMPDIR ]; then - mkdir $TMPDIR - chown -R 0:0 $TMPDIR - chmod -R 700 $TMPDIR - else - rm -rf $TMPDIR/* - fi - cd $TMPDIR - # Az md5sum állomány leszedáse - if [ -z $VERSION ]; then - wget "http://www.mayor.hu/download/md5sum" - else - wget "http://www.mayor.hu/download/$VERSION/md5sum" - if [[ ! $HTTP_SERVER =~ .*$VERSION.* ]]; then HTTP_SERVER="$HTTP_SERVER/$VERSION"; fi - fi - if [ $? != 0 ]; then exit 5; fi - UJ_REV=$(grep Revision md5sum | cut -d ' ' -f 2) - if [ "$REV" -lt "$UJ_REV" ]; then - # csomagok leszedése - for MODULE in $MODULES; do - echo -n " $MODULE... " - MOD=$(echo $MODULE | sed "s#/#-#") - FILE=$(grep "$MOD-rev" md5sum | cut -d ' ' -f 3) - if [ "$FILE" != '' ]; then - wget "$HTTP_SERVER/$FILE" - if [ $? != 0 ]; then - echo -e "\n\n ERROR: Az frissítés nem tölthető le: $FILE!\n" - exit 6 - fi - grep $FILE md5sum | md5sum -c --status - if [ $? == 0 ]; then - tar xfz $FILE -C $BASEDIR ./update - else - echo -e "\n\n ERROR: Az ellenörző összeg nem egyezik!\n" - exit 7 - fi - else - echo 'Nincs ilyen modul!' - exit 8 # nem szabad hiányzó csomagok mellett frissíteni!! - fi - done - fi - cd $BASEDIR/bin - fi - fi -else # exec-only - if [ -f $REVISION_FILE ]; then - UJ_REV=$(cat $REVISION_FILE) - else - UJ_REV=0 # nem frissítünk semmit - fi -fi - -if [ "$REV" -ge "$UJ_REV" ]; then - echo -e "\nNincs újabb változat.\n" - echo -e "\n * A szükséges jogosultságok beállítása:" - chmod +x $BASEDIR/bin/mayor - echo 'kész.' -else - echo 'kész.' - . $BASEDIR/update/processUpdateScripts.sh -fi - -PWDTEX=$(pwd) -echo -e "\nMaYoR TeX formátum állomány újragenerálása... " -cd $BASEDIR/print/module-naplo/tex/ && fmtutil-sys --cnffile $BASEDIR/print/module-naplo/tex/mayor.cnf --fmtdir $BASEDIR/print/module-naplo/ --byfmt mayor > /dev/null 2>&1 -echo -e "\nMaYoR XeTeX formátum állomány újragenerálása... " -cd $BASEDIR/print/module-naplo/xetex/ && fmtutil-sys --cnffile $BASEDIR/print/module-naplo/xetex/mayor-xetex.cnf --fmtdir $BASEDIR/print/module-naplo/ --byfmt mayor-xetex > /dev/null 2>&1 -cd $PWDTEX -echo 'kész.' - -echo -e "\nFrissítés vége.\n" -exit 0 diff --git a/mayor/bin/xetex2pdf.sh b/mayor/bin/xetex2pdf.sh deleted file mode 100644 index a4f7bf3f..00000000 --- a/mayor/bin/xetex2pdf.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# A script segítségével tesztelhetjük, hogy mi történik, mikor a program a haladásinaplót, illetve osztályozónaplót generálja -# __NYOMTATAS_XETEX===true beállítás mellett -# -# Paraméter: a feldolgozandó UTF-8 kódolású TeX állomány "-u8.tex" végződés nélküli neve. -# - -. /etc/mayor/main.conf - -HOME="/tmp" -export HOME - -# Make sure this exists -# cd $BASEDIR/print/module-naplo/tex/ -# fmtutil-sys --cnffile $BASEDIR/print/module-naplo/tex/mayor.cnf --fmtdir $BASEDIR/print/module-naplo/ --byfmt mayor - -cat < $1.tex -%\font\kicsi=ecrm0500 -%\font\nagy=ecbx1200 -%\font\vastag=ecsx0800 -%\font\nagyss=ecsx1200 -%\font\normal=ecss0800 -%\font\dolt=ecsi0800 - -\font\kicsi="Linux Libertine O" at 5pt -\font\nagy="Linux Libertine O/B" at 12pt -\font\nagyss="Arial/B" at 12pt -\font\normal="Linux Biolinum O" at 8pt -\font\dolt="Linux Biolinum O/I" at 8pt -\normal - -EOF -cat $1-u8.tex >> $1.tex -xetex -fmt $BASEDIR/print/module-naplo/xetex/mayor-xetex $1.tex - diff --git a/mayor/update/processUpdateScripts.sh b/mayor/update/processUpdateScripts.sh deleted file mode 100644 index 61ab5618..00000000 --- a/mayor/update/processUpdateScripts.sh +++ /dev/null @@ -1,267 +0,0 @@ -#!/bin/bash - -source $BASEDIR/update/linkme.sh - -# Setting Mysql Connection Parameters -echo -e "[mysqld] -character-set-server = utf8 -collation-server = utf8_hungarian_ci -[client] -default-character-set=utf8 -host=$MYSQL_HOST -user=$MYSQL_USER -password=$MYSQL_PW -" > $BASEDIR/config/my.cnf - -PRECHARSET="SET NAMES 'utf8' COLLATE 'utf8_hungarian_ci'; " ## fontos, hogy a ";" ott legyen a végén!! -#PRECHARSET="$PRECHARSET SET collation_connection = utf8_hungarian_ci; " ## ha a mysql server esetleg régebbi lenne. - -MYSQL_CONFIG="--defaults-extra-file=$BASEDIR/config/my.cnf" -MYSQL_PARAMETERS="" -TEST=$($MYSQL -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW -e exit 2>&1 >/dev/null) -if [ $? == "0" ]; then - echo "SQL-connect test #2 OK" - MYSQL_PARAMETERS="-h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW" -else - echo "Hibás SQL csatlakozás(2)" -fi -TEST=$($MYSQL $MYSQL_CONFIG -e exit 2>&1 >/dev/null) -if [ $? == "0" ]; then - echo "SQL-connect test #1 OK" - MYSQL_PARAMETERS=$MYSQL_CONFIG -else - echo "Hibás SQL csatlakozás(1)" -fi -echo "Karakterkódolás ellenőrzése" -echo "SHOW VARIABLES LIKE 'character%';" | $MYSQL $MYSQL_PARAMETERS -# patch by Acsai Gabor - FreeBSD -# Kiegészítve: Miklós Gergő - Baár-Madas -# gondolatmenet: -# A "default-character-set" beállítása után a "character_set_client" változóból 1db kell legyen, és értéke pontosan "utf8" kell legyen! -### TEST=`echo "SHOW VARIABLES LIKE 'character_set_client'" | $MYSQL $MYSQL_PARAMETERS | grep utf8 | wc -l | tr -d " "` -TEST=$(echo "SHOW VARIABLES LIKE '%character_set_client%'" | $MYSQL $MYSQL_PARAMETERS | tail -n+2 | cut -f 2) -if [ "$TEST" == "utf8" ]; then - echo "SQL-UTF8 test OK" -else - echo -e "\n\nERROR: Hibás - nem utf8 - MySQL kliens karakterkódolás!\n" - echo -e "Ellenőrizd a beállításokat és kérj segítséget a support@mayor.hu -n!\n" - exit 12 -fi -# -- - -run_script() { - FILEELEJE=$(echo $FILE | cut -f 1 -d '-') - FILEREV=${FILEELEJE: -6} - LOGSQL="" - if [ "$FILEREV" != "" ]; then - if [ "$FILEREV" -gt 3399 ]; then - LOGSQL="INSERT IGNORE mayorUpdateLog (scriptFile) VALUES ('${FILE}')" - fi - fi - if [ ! "${FILEREV}" \< "${REVSTR}" ]; then - FILEEXT=$(echo $FILE | cut -f 2 -d '.') - if [ "$FILEEXT" == "sh" ]; then - echo " - Szkript futtatása ($FILE)..." - . $FILE - if [ $? != 0 ]; then exit 13; fi - elif [ "$FILEEXT" == "sql" ]; then - echo " - SQL utasítások végrehajtása ($FILE)..." - FILEDB=$(echo $FILE | cut -f 1 -d '.' | cut -f 3 -d '-') - case "$FILEDB" in - naplo) - DBS=$DB_NAPLO - ;; - intezmeny) - DBS=$DB_INTEZMENY - ;; - auth) - DBS=$DB_AUTH - ;; - *) - DBS=$FILEDB - ;; - esac - for DB in $DBS; do - echo -e "\n $DB..." - - if [ "$FILEREV" != "" ]; then - if [ "$FILEREV" -gt 3399 ]; then - TEST=$((echo $PRECHARSET && echo "SELECT count(*) as db FROM information_schema.TABLES WHERE TABLE_SCHEMA='${DB}' and TABLE_NAME='mayorUpdateLog'") | $MYSQL $MYSQL_PARAMETERS $DB | grep -v "db") - if [ "$TEST" == "0" ]; then - echo " Hiányzik a mayorUpdateLog tábla... tovább..." - continue - fi - fi - fi - - case "$FILEDB" in - naplo) - INTEZMENYDB=$(echo $DB | sed -e 's/\(naplo_\)\(.*\)\(_.*\)/intezmeny_\2/') - INTEZMENYROVIDNEV=$(echo $DB | cut -f 2 -d '_') - TANEV=$(echo $DB | cut -f 3 -d '_') - (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENYDB%/$INTEZMENYDB/g" | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | \ - sed -e "s/%TANEV%/$TANEV/g" | $MYSQL $MYSQL_PARAMETERS $DB - ;; - auth) - (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%MYSQL_ENCODE_STR%/$MYSQL_ENCODE_STR/g" | $MYSQL $MYSQL_PARAMETERS $DB - ;; - intezmeny) - INTEZMENYROVIDNEV=$(echo $DB | cut -f 2 -d '_') - (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | $MYSQL $MYSQL_PARAMETERS $DB - ;; - *) - (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | $MYSQL $MYSQL_PARAMETERS $DB - ;; - esac - if [ $? != 0 ]; then - exit 13; - fi - done - [ ! -z $SQLLOG ] && echo $FILE >> $SQLLOG; - fi - fi -} - -echo " Az új változat verziószáma: $UJ_REV" - -REVSTR=$(printf "%06d" $REV) -MYSQL_ENCODE_STR=$(grep _MYSQL_ENCODE_STR $BASEDIR/config/main-config.php | sed -e "s/define('_MYSQL_ENCODE_STR','\(.*\)');/\\1/") - -# mysql host beállítása -if [ "$MYSQL_HOST" == "" ]; then - MYSQL_HOST="localhost" -fi -echo " A MySQL backend a következő lesz: $MYSQL_HOST" -echo " Figyelem! MySQL Master-Slave architekturát az upgrade script jelenleg nem támogat!!!" - -echo -e "\n * Adatbázisok lekérdezése..." -if [ -f $MYSQL ] -then - DB_MAYOR=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SHOW DATABASES LIKE 'mayor\_%'" | grep -e '^mayor\_[^_]*$') ## ide elvileg nem kellene precharset, mert itt minden ASCCI/2 - DB_NAPLO=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SHOW DATABASES LIKE 'naplo\_%\_%'" | grep -e '^naplo\_[^\_]*\_20[0-9][0-9]$') - DB_INTEZMENY=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SELECT CONCAT('intezmeny_',rovidNev) FROM mayor_naplo.intezmeny" | grep -e '^intezmeny\_[^\_]*$') -# DB_INTEZMENY=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'intezmeny\_%'" | grep -e '^intezmeny\_[^\_]*$'` - if [ $? != 0 ]; then exit 12; fi - DB_AUTH="" - for DB in $DB_MAYOR; do - if [ "$DB" == "mayor_parent" -o "$DB" == "mayor_private" -o "$DB" == "mayor_public" ]; then - DB_AUTH="$DB_AUTH $DB" - fi - done -else - echo -e "\n\nERROR: A mysql kliens nem található: $MYSQL\n" - exit 12 -fi - -if [ "$SKIPLOCK" != "1" ]; then - if [ ! -z $LOCKFILE ]; then - echo -e "\n * A web-es elérés letiltása:" - echo -n " - Lock-file létrehozása... " - echo "$DATE: Update process runing... " > $LOCKFILE - echo "kész." - - echo -n " - Aktív munkamenetek törlése... " - $MYSQL $MYSQL_PARAMETERS -e"DELETE FROM mayor_login.session" ##itt se kell, jó az ASCII - echo "kész." - fi -else - echo -e "\n * A lock-olást a kérésedre kihagyjuk..." -fi - -echo -e "\n * Az előzetes frissítő állományok feldolgozása (pre*, rev*):\n" -for FILE in $(ls $UPDATEDIR/rev* $UPDATEDIR/pre* | sort); do - run_script -done - -if [ "$EXECONLY" != "1" ]; then - echo -e "\n * A modulok állományainak frissítése:\n" - for MODULE in $MODULES; do - echo -e "\n $MODULE... \n" - if [ "$HTTP_SERVER" == '' ]; then - $SVN --force --quiet export https://svn.mayor.hu/svn/trunk/$MODULE "$BASEDIR" - if [ $? != 0 ]; then exit 13; fi - else - # Ha rpm csomag futtatja, akkor már ki van csomagolva minden és nincs md5sum - if [ -f $TMPDIR/md5sum ]; then - MOD=$(echo $MODULE | sed "s#/#-#") - FILE=$(grep "$MOD-rev" $TMPDIR/md5sum | cut -d ' ' -f 3) - if [ -f $TMPDIR/$FILE ]; then - tar xfz $TMPDIR/$FILE -C $BASEDIR - if [ $? != 0 ]; then exit 13; fi - fi - fi - fi - done - if [ -d $TMPDIR ]; then rm -rf $TMPDIR; fi - echo -e "\nkész.\n" -fi - -echo -e "\n * Az utólagos frissítő állományok feldolgozása (post*):\n" -for FILE in $(ls $UPDATEDIR/post* | sort); do - run_script -done - - -if [ -e $LOCKFILE ]; then - if [ ! -z $LOCKFILE ]; then - echo -e "\n * A web-es hozzáférés engedélyezése:" - rm $LOCKFILE - fi -fi - -if [ "$EXECONLY" != "1" ]; then - echo -e "\n * A szükséges jogosultságok beállítása:" - chmod +x $BASEDIR/bin/mayor - echo -n " ... " - chown -R $WEB_SERVER_USER $BASEDIR/download - chown -R $WEB_SERVER_USER $BASEDIR/cache - if [ -d $BASEDIR/www/wiki/conf ]; then - chown -R $WEB_SERVER_USER $BASEDIR/www/wiki/conf $BASEDIR/www/wiki/data - fi - chown $WEB_SERVER_USER $BASEDIR/config - chmod 700 $BASEDIR/config - echo -e "... kész.\n" - - echo -e "\n * Szimbolikus linkek ellenőrzése/létrehozása" - POLICIES="parent public" - for POLICY in $POLICIES; do - eval "LIST=\$${POLICY}Link" - for f in $LIST; do - DIR=$(echo $f | cut -d / -f 1-2) - if [ ! -d $BASEDIR/www/policy/$POLICY/$DIR ]; then - echo " Könyvtár: $BASEDIR/www/policy/$POLICY/$DIR" - mkdir -p $BASEDIR/www/policy/$POLICY/$DIR - fi - FILES="$f-pre.php $f.php" - for file in $FILES; do - if [ ! -e $BASEDIR/www/policy/$POLICY/$file ]; then - if [ -f $BASEDIR/www/policy/private/$file ]; then - echo " $BASEDIR/www/policy/private/$file --> $BASEDIR/www/policy/$POLICY/$file" - ln -s $BASEDIR/www/policy/private/$file $BASEDIR/www/policy/$POLICY/$file - else - echo " Hiányzó file: $BASEDIR/www/policy/private/$file" - fi - fi - done - done - eval "DLIST=\$${POLICY}Deny" - for f in $DLIST; do - FILES="$f-pre.php $f.php" - for file in $FILES; do - if [ -e $BASEDIR/www/policy/$POLICY/$file ]; then - echo " $BASEDIR/www/policy/$POLICY/$file link(file) törlése" - rm "$BASEDIR/www/policy/$POLICY/$file" - fi - done - done - done -fi # execonly - -echo -e "\n * Az frissített verziószám rögzítése ($UJ_REV)" -if [ "$UJ_REV" -gt 0 ]; then - echo $UJ_REV > $REVISION_FILE -else - echo " Hibás (nulla) verziószám! Nem rögzítjük." -fi - -[ -x "$LOCAL_UPDATE_SCRIPT" ] && echo -e "\n * Helyi szkript futtatása: $LOCAL_UPDATE_SCRIPT...\n " && . "$LOCAL_UPDATE_SCRIPT" diff --git a/mayor/update/processUpdateScripts.sh.mod.txt b/mayor/update/processUpdateScripts.sh.mod.txt deleted file mode 100644 index 3168b48d..00000000 --- a/mayor/update/processUpdateScripts.sh.mod.txt +++ /dev/null @@ -1,183 +0,0 @@ ---- processUpdateScripts.sh.orig 2016-03-04 13:44:39.000000000 +0100 -+++ processUpdateScripts.sh 2018-03-04 14:10:13.835309914 +0100 -@@ -6,22 +6,26 @@ - echo -e "[mysqld] - character-set-server = utf8 - collation-server = utf8_hungarian_ci --skip-character-set-client-handshake - [client] -+default-character-set=utf8 - host=$MYSQL_HOST - user=$MYSQL_USER - password=$MYSQL_PW - " > $BASEDIR/config/my.cnf -+ -+PRECHARSET="SET NAMES 'utf8' COLLATE 'utf8_hungarian_ci'; " ## fontos, hogy a ";" ott legyen a végén!! -+#PRECHARSET="$PRECHARSET SET collation_connection = utf8_hungarian_ci; " ## ha a mysql server esetleg régebbi lenne. -+ - MYSQL_CONFIG="--defaults-extra-file=$BASEDIR/config/my.cnf" - MYSQL_PARAMETERS="" --TEST=`$MYSQL -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW -e exit 2>&1 >/dev/null` -+TEST=$($MYSQL -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW -e exit 2>&1 >/dev/null) - if [ $? == "0" ]; then - echo "SQL-connect test #2 OK" - MYSQL_PARAMETERS="-h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW" - else - echo "Hibás SQL csatlakozás(2)" - fi --TEST=`$MYSQL $MYSQL_CONFIG -e exit 2>&1 >/dev/null` -+TEST=$($MYSQL $MYSQL_CONFIG -e exit 2>&1 >/dev/null) - if [ $? == "0" ]; then - echo "SQL-connect test #1 OK" - MYSQL_PARAMETERS=$MYSQL_CONFIG -@@ -31,8 +35,12 @@ - echo "Karakterkódolás ellenőrzése" - echo "SHOW VARIABLES LIKE 'character%';" | $MYSQL $MYSQL_PARAMETERS - # patch by Acsai Gabor - FreeBSD --TEST=`echo "SHOW VARIABLES LIKE 'character_set_client'" | $MYSQL $MYSQL_PARAMETERS | grep utf8 | wc -l | tr -d " "` --if [ "x${TEST}" == "x1" ]; then -+# Kiegészítve: Miklós Gergő - Baár-Madas -+# gondolatmenet: -+# A "default-character-set" beállítása után a "character_set_client" változóból 1db kell legyen, és értéke pontosan "utf8" kell legyen! -+### TEST=`echo "SHOW VARIABLES LIKE 'character_set_client'" | $MYSQL $MYSQL_PARAMETERS | grep utf8 | wc -l | tr -d " "` -+TEST=$(echo "SHOW VARIABLES LIKE '%character_set_client%'" | $MYSQL $MYSQL_PARAMETERS | tail -n+2 | cut -f 2) -+if [ "$TEST" == "utf8" ]; then - echo "SQL-UTF8 test OK" - else - echo -e "\n\nERROR: Hibás - nem utf8 - MySQL kliens karakterkódolás!\n" -@@ -42,7 +50,7 @@ - # -- - - run_script() { -- FILEELEJE=`echo $FILE | cut -f 1 -d '-'` -+ FILEELEJE=$(echo $FILE | cut -f 1 -d '-') - FILEREV=${FILEELEJE: -6} - LOGSQL="" - if [ "$FILEREV" != "" ]; then -@@ -51,14 +59,14 @@ - fi - fi - if [ ! "${FILEREV}" \< "${REVSTR}" ]; then -- FILEEXT=`echo $FILE | cut -f 2 -d '.'` -+ FILEEXT=$(echo $FILE | cut -f 2 -d '.') - if [ "$FILEEXT" == "sh" ]; then - echo " - Szkript futtatása ($FILE)..." - . $FILE - if [ $? != 0 ]; then exit 13; fi - elif [ "$FILEEXT" == "sql" ]; then - echo " - SQL utasítások végrehajtása ($FILE)..." -- FILEDB=`echo $FILE | cut -f 1 -d '.' | cut -f 3 -d '-'` -+ FILEDB=$(echo $FILE | cut -f 1 -d '.' | cut -f 3 -d '-') - case "$FILEDB" in - naplo) - DBS=$DB_NAPLO -@@ -78,7 +86,7 @@ - - if [ "$FILEREV" != "" ]; then - if [ "$FILEREV" -gt 3399 ]; then -- TEST=`echo "SELECT count(*) as db FROM information_schema.TABLES WHERE TABLE_SCHEMA='${DB}' and TABLE_NAME='mayorUpdateLog'" | $MYSQL $MYSQL_PARAMETERS $DB | grep -v "db"` -+ TEST=$((echo $PRECHARSET && echo "SELECT count(*) as db FROM information_schema.TABLES WHERE TABLE_SCHEMA='${DB}' and TABLE_NAME='mayorUpdateLog'") | $MYSQL $MYSQL_PARAMETERS $DB | grep -v "db") - if [ "$TEST" == "0" ]; then - echo " Hiányzik a mayorUpdateLog tábla... tovább..." - continue -@@ -88,21 +96,21 @@ - - case "$FILEDB" in - naplo) -- INTEZMENYDB=`echo $DB | sed -e 's/\(naplo_\)\(.*\)\(_.*\)/intezmeny_\2/'` -- INTEZMENYROVIDNEV=`echo $DB | cut -f 2 -d '_'` -- TANEV=`echo $DB | cut -f 3 -d '_'` -- (cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENYDB%/$INTEZMENYDB/g" | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | \ -+ INTEZMENYDB=$(echo $DB | sed -e 's/\(naplo_\)\(.*\)\(_.*\)/intezmeny_\2/') -+ INTEZMENYROVIDNEV=$(echo $DB | cut -f 2 -d '_') -+ TANEV=$(echo $DB | cut -f 3 -d '_') -+ (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENYDB%/$INTEZMENYDB/g" | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | \ - sed -e "s/%TANEV%/$TANEV/g" | $MYSQL $MYSQL_PARAMETERS $DB - ;; - auth) -- (cat $FILE && echo "${LOGSQL}") | sed -e "s/%MYSQL_ENCODE_STR%/$MYSQL_ENCODE_STR/g" | $MYSQL $MYSQL_PARAMETERS $DB -+ (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%MYSQL_ENCODE_STR%/$MYSQL_ENCODE_STR/g" | $MYSQL $MYSQL_PARAMETERS $DB - ;; - intezmeny) -- INTEZMENYROVIDNEV=`echo $DB | cut -f 2 -d '_'` -- (cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | $MYSQL $MYSQL_PARAMETERS $DB -+ INTEZMENYROVIDNEV=$(echo $DB | cut -f 2 -d '_') -+ (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | $MYSQL $MYSQL_PARAMETERS $DB - ;; - *) -- (cat $FILE && echo "${LOGSQL}") | $MYSQL $MYSQL_PARAMETERS $DB -+ (echo $PRECHARSET && cat $FILE && echo "${LOGSQL}") | $MYSQL $MYSQL_PARAMETERS $DB - ;; - esac - if [ $? != 0 ]; then -@@ -116,8 +124,8 @@ - - echo " Az új változat verziószáma: $UJ_REV" - --REVSTR=`printf "%06d" $REV` --MYSQL_ENCODE_STR=`grep _MYSQL_ENCODE_STR $BASEDIR/config/main-config.php | sed -e "s/define('_MYSQL_ENCODE_STR','\(.*\)');/\\1/"` -+REVSTR=$(printf "%06d" $REV) -+MYSQL_ENCODE_STR=$(grep _MYSQL_ENCODE_STR $BASEDIR/config/main-config.php | sed -e "s/define('_MYSQL_ENCODE_STR','\(.*\)');/\\1/") - - # mysql host beállítása - if [ "$MYSQL_HOST" == "" ]; then -@@ -129,9 +137,9 @@ - echo -e "\n * Adatbázisok lekérdezése..." - if [ -f $MYSQL ] - then -- DB_MAYOR=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'mayor\_%'" | grep -e '^mayor\_[^_]*$'` -- DB_NAPLO=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'naplo\_%\_%'" | grep -e '^naplo\_[^\_]*\_20[0-9][0-9]$'` -- DB_INTEZMENY=`$MYSQL $MYSQL_PARAMETERS -e"SELECT CONCAT('intezmeny_',rovidNev) FROM mayor_naplo.intezmeny" | grep -e '^intezmeny\_[^\_]*$'` -+ DB_MAYOR=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SHOW DATABASES LIKE 'mayor\_%'" | grep -e '^mayor\_[^_]*$') ## ide elvileg nem kellene precharset, mert itt minden ASCCI/2 -+ DB_NAPLO=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SHOW DATABASES LIKE 'naplo\_%\_%'" | grep -e '^naplo\_[^\_]*\_20[0-9][0-9]$') -+ DB_INTEZMENY=$($MYSQL $MYSQL_PARAMETERS -e"$PRECHARSET SELECT CONCAT('intezmeny_',rovidNev) FROM mayor_naplo.intezmeny" | grep -e '^intezmeny\_[^\_]*$') - # DB_INTEZMENY=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'intezmeny\_%'" | grep -e '^intezmeny\_[^\_]*$'` - if [ $? != 0 ]; then exit 12; fi - DB_AUTH="" -@@ -153,7 +161,7 @@ - echo "kész." - - echo -n " - Aktív munkamenetek törlése... " -- $MYSQL $MYSQL_PARAMETERS -e"DELETE FROM mayor_login.session" -+ $MYSQL $MYSQL_PARAMETERS -e"DELETE FROM mayor_login.session" ##itt se kell, jó az ASCII - echo "kész." - fi - else -@@ -161,7 +169,7 @@ - fi - - echo -e "\n * Az előzetes frissítő állományok feldolgozása (pre*, rev*):\n" --for FILE in `ls $UPDATEDIR/rev* $UPDATEDIR/pre* | sort`; do -+for FILE in $(ls $UPDATEDIR/rev* $UPDATEDIR/pre* | sort); do - run_script - done - -@@ -175,8 +183,8 @@ - else - # Ha rpm csomag futtatja, akkor már ki van csomagolva minden és nincs md5sum - if [ -f $TMPDIR/md5sum ]; then -- MOD=`echo $MODULE | sed "s#/#-#"` -- FILE=`grep "$MOD-rev" $TMPDIR/md5sum | cut -d ' ' -f 3` -+ MOD=$(echo $MODULE | sed "s#/#-#") -+ FILE=$(grep "$MOD-rev" $TMPDIR/md5sum | cut -d ' ' -f 3) - if [ -f $TMPDIR/$FILE ]; then - tar xfz $TMPDIR/$FILE -C $BASEDIR - if [ $? != 0 ]; then exit 13; fi -@@ -189,7 +197,7 @@ - fi - - echo -e "\n * Az utólagos frissítő állományok feldolgozása (post*):\n" --for FILE in `ls $UPDATEDIR/post* | sort`; do -+for FILE in $(ls $UPDATEDIR/post* | sort); do - run_script - done - -@@ -219,7 +227,7 @@ - for POLICY in $POLICIES; do - eval "LIST=\$${POLICY}Link" - for f in $LIST; do -- DIR=`echo $f | cut -d / -f 1-2` -+ DIR=$(echo $f | cut -d / -f 1-2) - if [ ! -d $BASEDIR/www/policy/$POLICY/$DIR ]; then - echo " Könyvtár: $BASEDIR/www/policy/$POLICY/$DIR" - mkdir -p $BASEDIR/www/policy/$POLICY/$DIR diff --git a/mayor/update/processUpdateScripts.sh.orig b/mayor/update/processUpdateScripts.sh.orig deleted file mode 100644 index 47fbb23e..00000000 --- a/mayor/update/processUpdateScripts.sh.orig +++ /dev/null @@ -1,259 +0,0 @@ -#!/bin/bash - -source $BASEDIR/update/linkme.sh - -# Setting Mysql Connection Parameters -echo -e "[mysqld] -character-set-server = utf8 -collation-server = utf8_hungarian_ci -skip-character-set-client-handshake -[client] -host=$MYSQL_HOST -user=$MYSQL_USER -password=$MYSQL_PW -" > $BASEDIR/config/my.cnf -MYSQL_CONFIG="--defaults-extra-file=$BASEDIR/config/my.cnf" -MYSQL_PARAMETERS="" -TEST=`$MYSQL -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW -e exit 2>&1 >/dev/null` -if [ $? == "0" ]; then - echo "SQL-connect test #2 OK" - MYSQL_PARAMETERS="-h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PW" -else - echo "Hibás SQL csatlakozás(2)" -fi -TEST=`$MYSQL $MYSQL_CONFIG -e exit 2>&1 >/dev/null` -if [ $? == "0" ]; then - echo "SQL-connect test #1 OK" - MYSQL_PARAMETERS=$MYSQL_CONFIG -else - echo "Hibás SQL csatlakozás(1)" -fi -echo "Karakterkódolás ellenőrzése" -echo "SHOW VARIABLES LIKE 'character%';" | $MYSQL $MYSQL_PARAMETERS -# patch by Acsai Gabor - FreeBSD -TEST=`echo "SHOW VARIABLES LIKE 'character_set_client'" | $MYSQL $MYSQL_PARAMETERS | grep utf8 | wc -l | tr -d " "` -if [ "x${TEST}" == "x1" ]; then - echo "SQL-UTF8 test OK" -else - echo -e "\n\nERROR: Hibás - nem utf8 - MySQL kliens karakterkódolás!\n" - echo -e "Ellenőrizd a beállításokat és kérj segítséget a support@mayor.hu -n!\n" - exit 12 -fi -# -- - -run_script() { - FILEELEJE=`echo $FILE | cut -f 1 -d '-'` - FILEREV=${FILEELEJE: -6} - LOGSQL="" - if [ "$FILEREV" != "" ]; then - if [ "$FILEREV" -gt 3399 ]; then - LOGSQL="INSERT IGNORE mayorUpdateLog (scriptFile) VALUES ('${FILE}')" - fi - fi - if [ ! "${FILEREV}" \< "${REVSTR}" ]; then - FILEEXT=`echo $FILE | cut -f 2 -d '.'` - if [ "$FILEEXT" == "sh" ]; then - echo " - Szkript futtatása ($FILE)..." - . $FILE - if [ $? != 0 ]; then exit 13; fi - elif [ "$FILEEXT" == "sql" ]; then - echo " - SQL utasítások végrehajtása ($FILE)..." - FILEDB=`echo $FILE | cut -f 1 -d '.' | cut -f 3 -d '-'` - case "$FILEDB" in - naplo) - DBS=$DB_NAPLO - ;; - intezmeny) - DBS=$DB_INTEZMENY - ;; - auth) - DBS=$DB_AUTH - ;; - *) - DBS=$FILEDB - ;; - esac - for DB in $DBS; do - echo -e "\n $DB..." - - if [ "$FILEREV" != "" ]; then - if [ "$FILEREV" -gt 3399 ]; then - TEST=`echo "SELECT count(*) as db FROM information_schema.TABLES WHERE TABLE_SCHEMA='${DB}' and TABLE_NAME='mayorUpdateLog'" | $MYSQL $MYSQL_PARAMETERS $DB | grep -v "db"` - if [ "$TEST" == "0" ]; then - echo " Hiányzik a mayorUpdateLog tábla... tovább..." - continue - fi - fi - fi - - case "$FILEDB" in - naplo) - INTEZMENYDB=`echo $DB | sed -e 's/\(naplo_\)\(.*\)\(_.*\)/intezmeny_\2/'` - INTEZMENYROVIDNEV=`echo $DB | cut -f 2 -d '_'` - TANEV=`echo $DB | cut -f 3 -d '_'` - (cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENYDB%/$INTEZMENYDB/g" | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | \ - sed -e "s/%TANEV%/$TANEV/g" | $MYSQL $MYSQL_PARAMETERS $DB - ;; - auth) - (cat $FILE && echo "${LOGSQL}") | sed -e "s/%MYSQL_ENCODE_STR%/$MYSQL_ENCODE_STR/g" | $MYSQL $MYSQL_PARAMETERS $DB - ;; - intezmeny) - INTEZMENYROVIDNEV=`echo $DB | cut -f 2 -d '_'` - (cat $FILE && echo "${LOGSQL}") | sed -e "s/%INTEZMENY%/$INTEZMENYROVIDNEV/g" | $MYSQL $MYSQL_PARAMETERS $DB - ;; - *) - (cat $FILE && echo "${LOGSQL}") | $MYSQL $MYSQL_PARAMETERS $DB - ;; - esac - if [ $? != 0 ]; then - exit 13; - fi - done - [ ! -z $SQLLOG ] && echo $FILE >> $SQLLOG; - fi - fi -} - -echo " Az új változat verziószáma: $UJ_REV" - -REVSTR=`printf "%06d" $REV` -MYSQL_ENCODE_STR=`grep _MYSQL_ENCODE_STR $BASEDIR/config/main-config.php | sed -e "s/define('_MYSQL_ENCODE_STR','\(.*\)');/\\1/"` - -# mysql host beállítása -if [ "$MYSQL_HOST" == "" ]; then - MYSQL_HOST="localhost" -fi -echo " A MySQL backend a következő lesz: $MYSQL_HOST" -echo " Figyelem! MySQL Master-Slave architekturát az upgrade script jelenleg nem támogat!!!" - -echo -e "\n * Adatbázisok lekérdezése..." -if [ -f $MYSQL ] -then - DB_MAYOR=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'mayor\_%'" | grep -e '^mayor\_[^_]*$'` - DB_NAPLO=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'naplo\_%\_%'" | grep -e '^naplo\_[^\_]*\_20[0-9][0-9]$'` - DB_INTEZMENY=`$MYSQL $MYSQL_PARAMETERS -e"SELECT CONCAT('intezmeny_',rovidNev) FROM mayor_naplo.intezmeny" | grep -e '^intezmeny\_[^\_]*$'` -# DB_INTEZMENY=`$MYSQL $MYSQL_PARAMETERS -e"SHOW DATABASES LIKE 'intezmeny\_%'" | grep -e '^intezmeny\_[^\_]*$'` - if [ $? != 0 ]; then exit 12; fi - DB_AUTH="" - for DB in $DB_MAYOR; do - if [ "$DB" == "mayor_parent" -o "$DB" == "mayor_private" -o "$DB" == "mayor_public" ]; then - DB_AUTH="$DB_AUTH $DB" - fi - done -else - echo -e "\n\nERROR: A mysql kliens nem található: $MYSQL\n" - exit 12 -fi - -if [ "$SKIPLOCK" != "1" ]; then - if [ ! -z $LOCKFILE ]; then - echo -e "\n * A web-es elérés letiltása:" - echo -n " - Lock-file létrehozása... " - echo "$DATE: Update process runing... " > $LOCKFILE - echo "kész." - - echo -n " - Aktív munkamenetek törlése... " - $MYSQL $MYSQL_PARAMETERS -e"DELETE FROM mayor_login.session" - echo "kész." - fi -else - echo -e "\n * A lock-olást a kérésedre kihagyjuk..." -fi - -echo -e "\n * Az előzetes frissítő állományok feldolgozása (pre*, rev*):\n" -for FILE in `ls $UPDATEDIR/rev* $UPDATEDIR/pre* | sort`; do - run_script -done - -if [ "$EXECONLY" != "1" ]; then - echo -e "\n * A modulok állományainak frissítése:\n" - for MODULE in $MODULES; do - echo -e "\n $MODULE... \n" - if [ "$HTTP_SERVER" == '' ]; then - $SVN --force --quiet export https://svn.mayor.hu/svn/trunk/$MODULE "$BASEDIR" - if [ $? != 0 ]; then exit 13; fi - else - # Ha rpm csomag futtatja, akkor már ki van csomagolva minden és nincs md5sum - if [ -f $TMPDIR/md5sum ]; then - MOD=`echo $MODULE | sed "s#/#-#"` - FILE=`grep "$MOD-rev" $TMPDIR/md5sum | cut -d ' ' -f 3` - if [ -f $TMPDIR/$FILE ]; then - tar xfz $TMPDIR/$FILE -C $BASEDIR - if [ $? != 0 ]; then exit 13; fi - fi - fi - fi - done - if [ -d $TMPDIR ]; then rm -rf $TMPDIR; fi - echo -e "\nkész.\n" -fi - -echo -e "\n * Az utólagos frissítő állományok feldolgozása (post*):\n" -for FILE in `ls $UPDATEDIR/post* | sort`; do - run_script -done - - -if [ -e $LOCKFILE ]; then - if [ ! -z $LOCKFILE ]; then - echo -e "\n * A web-es hozzáférés engedélyezése:" - rm $LOCKFILE - fi -fi - -if [ "$EXECONLY" != "1" ]; then - echo -e "\n * A szükséges jogosultságok beállítása:" - chmod +x $BASEDIR/bin/mayor - echo -n " ... " - chown -R $WEB_SERVER_USER $BASEDIR/download - chown -R $WEB_SERVER_USER $BASEDIR/cache - if [ -d $BASEDIR/www/wiki/conf ]; then - chown -R $WEB_SERVER_USER $BASEDIR/www/wiki/conf $BASEDIR/www/wiki/data - fi - chown $WEB_SERVER_USER $BASEDIR/config - chmod 700 $BASEDIR/config - echo -e "... kész.\n" - - echo -e "\n * Szimbolikus linkek ellenőrzése/létrehozása" - POLICIES="parent public" - for POLICY in $POLICIES; do - eval "LIST=\$${POLICY}Link" - for f in $LIST; do - DIR=`echo $f | cut -d / -f 1-2` - if [ ! -d $BASEDIR/www/policy/$POLICY/$DIR ]; then - echo " Könyvtár: $BASEDIR/www/policy/$POLICY/$DIR" - mkdir -p $BASEDIR/www/policy/$POLICY/$DIR - fi - FILES="$f-pre.php $f.php" - for file in $FILES; do - if [ ! -e $BASEDIR/www/policy/$POLICY/$file ]; then - if [ -f $BASEDIR/www/policy/private/$file ]; then - echo " $BASEDIR/www/policy/private/$file --> $BASEDIR/www/policy/$POLICY/$file" - ln -s $BASEDIR/www/policy/private/$file $BASEDIR/www/policy/$POLICY/$file - else - echo " Hiányzó file: $BASEDIR/www/policy/private/$file" - fi - fi - done - done - eval "DLIST=\$${POLICY}Deny" - for f in $DLIST; do - FILES="$f-pre.php $f.php" - for file in $FILES; do - if [ -e $BASEDIR/www/policy/$POLICY/$file ]; then - echo " $BASEDIR/www/policy/$POLICY/$file link(file) törlése" - rm "$BASEDIR/www/policy/$POLICY/$file" - fi - done - done - done -fi # execonly - -echo -e "\n * Az frissített verziószám rögzítése ($UJ_REV)" -if [ "$UJ_REV" -gt 0 ]; then - echo $UJ_REV > $REVISION_FILE -else - echo " Hibás (nulla) verziószám! Nem rögzítjük." -fi - -[ -x "$LOCAL_UPDATE_SCRIPT" ] && echo -e "\n * Helyi szkript futtatása: $LOCAL_UPDATE_SCRIPT...\n " && . "$LOCAL_UPDATE_SCRIPT" diff --git a/mayor/www/include/modules/naplo/share/file.php b/mayor/www/include/modules/naplo/share/file.php deleted file mode 100644 index 1e6c7595..00000000 --- a/mayor/www/include/modules/naplo/share/file.php +++ /dev/null @@ -1,662 +0,0 @@ - _ATTR_DIAKID, - 'oid' => _ATTR_OID, - 'diakigazolvanyszam' => _ATTR_IGAZOLVANYSZAM, - 'viseltnevelotag' => _ATTR_VNE, - 'viseltcsaladinev' => _ATTR_VCSN, - 'viseltutonev' => _ATTR_VUN, - 'szuleteskorinevelotag' => _ATTR_SZNE, - 'szuleteskoricsaladinev' => _ATTR_SZCSN, - 'szuleteskoriutonev' => _ATTR_SZUN, - 'szuletesihely' => _ATTR_SZH, - 'szuletesiido' => _ATTR_SZI, - 'anyanevelotag' => _ATTR_ANE, - 'anyacsaladinev' => _ATTR_ACSN, - 'anyautoneve' => _ATTR_AUN, - 'kezdotanev' => _ATTR_KEZDO_TANEV, - 'kezdoszemeszter' => _ATTR_KEZDO_SZEMESZTER, - 'vegzotanev' => _ATTR_VEGZO_TANEV, - 'vegzoszemeszter' => _ATTR_VEGZO_SZEMESZTER, - 'adoazonosito' => _ATTR_ADOAZONOSITO, - 'allampolgarsag' => _ATTR_ALLAMPOLGARSAG, - 'anyaid' => _ATTR_ANYAID, - 'apaid' => _ATTR_APAID, - 'gondviseloid' => _ATTR_GONDVISELOID, - 'neveloid' => _ATTR_NEVELOID, - 'diaknaplosorszam' => _ATTR_DIAKNAPLOSORSZAM, - 'elozoiskolaomkod' => _ATTR_ELOZOISKOLAOMKOD, - 'email' => _ATTR_EMAIL, - 'fogyatekossag' => _ATTR_FOGYATEKOSSAG, - 'gondozasiszam' => _ATTR_GONDOZASISZAM, - 'jogviszonykezdete' => _ATTR_JOGVISZONYKEZDETE, - 'jogviszonyvege' => _ATTR_JOGVISZONYVEGE, - - 'lakhelyorszag' => _ATTR_LAKHELY_ORSZAG, - 'lakhelyirsz' => _ATTR_LAKHELY_IRSZ, - 'lakhelyhelyseg' => _ATTR_LAKHELY_HELYSEG, - 'lakhelykozteruletnev' => _ATTR_LAKHELY_KOZTERULETNEV, - 'lakhelykozteruletjelleg' => _ATTR_LAKHELY_KOZTERULETJELLEG, - 'lakhelyhazszam' => _ATTR_LAKHELY_HAZSZAM, - 'lakhelyemelet' => _ATTR_LAKHELY_EMELET, - 'lakhelyajto' => _ATTR_LAKHELY_AJTO, - - 'tartorszag' => _ATTR_TART_ORSZAG, - 'tartirsz' => _ATTR_TART_IRSZ, - 'tarthelyseg' => _ATTR_TART_HELYSEG, - 'tartkozteruletnev' => _ATTR_TART_KOZTERULETNEV, - 'tartkozteruletjelleg' => _ATTR_TART_KOZTERULETJELLEG, - 'tarthazszam' => _ATTR_TART_HAZSZAM, - 'tartemelet' => _ATTR_TART_EMELET, - 'tartajto' => _ATTR_TART_AJTO, - - 'tajszam' => _ATTR_TAJSZAM, - 'osztalyjel' => _ATTR_OSZTALYJEL, - 'penzugyistatusz' => _ATTR_PENZUGYISTATUSZ, - 'szemelyiigazolvanyszam' => _ATTR_SZEMELYIIGAZOLVANYSZAM, - 'szocialishelyzet' => _ATTR_SZOCIALISHELYZET, - 'statusz' => _ATTR_STATUSZ, - 'tartozkodasiokiratszam' => _ATTR_TARTOZKODASIOKIRATSZAM, - 'torvenyeskepviselo' => _ATTR_TORVENYESKEPVISELO, - 'telefon' => _ATTR_TELEFON, - 'mobil' => _ATTR_MOBIL, - 'nem' => _ATTR_NEM, - 'lakohelyijellemzo' => _ATTR_LAKOHELYIJELLEMZO, - 'megjegyzes' => _ATTR_MEGJEGYZES, - ); - - function readUpdateFile($fileName, $mezo_elvalaszto = ' ') { - - - $ADATOK = array(); - if ($fp = @fopen($fileName,'r')) { - // Az első 50 sor beolvasása - minta a mező-hozzárendeléshez - $i=0; - while (($sor = fgets($fp,1024)) and ($i<50)) { - $ADATOK[$i] = explode($mezo_elvalaszto,chop($sor)); - $i++; - } - fclose($fp); - } else { - $_SESSION['alert'][] = 'message:file_open_error:'.$fileName; - } - - return $ADATOK; - } -/* - * Lekérdezi egy adatbázis (naplo_intezmeny, naplo (tanév)) egy adott táblájának mezőit. - * Ha szükséges ezek listáját kiegészíti az extraAttrs tömbben felsorolt mezőkkel. - * A mezőnevekhez nyelvi konstansokat rendelhetünk ($Attrs tömb és lang/.../share/file.php) - */ - function getTableFields($table, $db = 'naplo_intezmeny', $extraAttrs = array(), $SET = array('withType' => false)) { - - global $Attrs; - - $return = $type = $name = array(); - $q = "SHOW FIELDS FROM `%s`"; - $r = db_query($q, array('fv' => 'getTableFields','modul' => $db, 'result' => 'indexed', 'values' => array($table))); - for ($i = 0; $i < count($r); $i++) { - if ($SET['withType']) { - if (substr($r[$i]['Type'],0,7) == 'varchar') $type[ $r[$i]['Field'] ] = 'string'; - elseif (substr($r[$i]['Type'],0,4) == 'enum') $type[ $r[$i]['Field'] ] = 'enum'; - elseif (substr($r[$i]['Type'],0,4) == 'date') $type[ $r[$i]['Field'] ] = 'date'; - elseif (strpos($r[$i]['Type'],'int(') !== false) $type[ $r[$i]['Field'] ] = 'int'; - else $type[ $r[$i]['Field'] ] = 'string'; - } - if ($Attrs[kisbetus($r[$i]['Field'])] != '') $name[$r[$i]['Field']] = $Attrs[kisbetus($r[$i]['Field'])]; - else $name[$r[$i]['Field']] = $r[$i]['Field']; - } - for ($i = 0; $i < count($extraAttrs); $i++) { - if (!isset($name[$extraAttrs[$i]])) { - if ($Attrs[kisbetus($extraAttrs[$i])] != '') $name[$extraAttrs[$i]] = $Attrs[kisbetus($extraAttrs[$i])]; - else $name[$extraAttrs[$i]] = $extraAttrs[$i]; - } - } - ksort($name); - - if ($SET['withType']) return array('names' => $name, 'types' => $type); - return $name; - - } - - - function getEnumField($modul, $table, $field) { - - $table = '`'.str_replace('.','`.`',$table).'`'; - $q = "SHOW FIELDS FROM %s LIKE '%s'"; - $v = array($table, $field); - $field = db_query($q, array('fv' => 'getEnumField', 'modul' => $modul, 'result' => 'record', 'values' => $v)); - $enum = substr($field['Type'], 6, -2); - $values = explode("','", $enum); - - return $values; - } - - function getSetField($modul, $table, $field) { - - $table = '`'.str_replace('.','`.`',$table).'`'; - $q = "SHOW FIELDS FROM %s LIKE '%s'"; - $v = array($table, $field); - $field = db_query($q, array('fv' => 'getSetField', 'modul' => $modul, 'result' => 'record', 'values' => $v)); - $set = substr($field['Type'], 5, -2); - $values = explode("','", $set); - - return $values; - } - - - function updateTable($table, $file, $MEZO_LISTA, $KULCS_MEZOK, $mezo_elvalaszto = ' ', $rovatfej = false, $db = 'naplo_intezmeny') { - - - if (!file_exists($file)) { - $_SESSION['alert'][] = 'message:file_not_found:updateTable:'.$file; - return false; - } - - if (!is_array($MEZO_LISTA)) { - $_SESSION['alert'][] = 'message:wrong_data:updateTable:MEZO_LISTA'; - return false; - } - - if (!is_array($KULCS_MEZOK)) { - $_SESSION['alert'][] = 'message:wrong_data:updateTable:KULCS_MEZOK'; - return false; - } - - // A frissítendő attribútumok listája - $attrList = array_values(array_filter($MEZO_LISTA)); - - $fp = fopen($file,'r'); - if (!$fp) { - $_SESSION['alert'][] = 'message:file_open_error:updateTable:'.$file; - return false; - } - - $lr = db_connect($db, array('fv' => 'updateTable')); - if (!$lr) { - $_SESSION['alert'][] = 'message:db_connect_failure:updateTable'; - fclose($fp); - return false; - } - db_start_trans($lr); - - // Az első sor kihagyása - if ($rovatfej) $sor = fgets($fp,1024); - while ($sor = fgets($fp,1024)) { - - $insertValues = $insertPatterns = array(); - $adatSor = explode($mezo_elvalaszto,chop($sor)); - $update = false; - - // keresési feltétel összerakása - $where = $v = $vw = array(); - for ($i = 0; $i < count($KULCS_MEZOK); $i++) { - if ($adatSor[$KULCS_MEZOK[$i]] != '') { - $where[] = "`%s`='%s'"; - array_push($vw, $MEZO_LISTA[$KULCS_MEZOK[$i]], $adatSor[$KULCS_MEZOK[$i]]); - } - } - $num = 0; - if (count($where) != 0) { - $q = 'SELECT COUNT(*) FROM `%s` WHERE '.implode(' AND ', $where); - array_unshift($vw, $table); - $num = db_query($q, array('fv' => 'updateTable', 'values' => $vw, 'result' => 'value', 'modul' => $db), $lr); - } - if ($num == 1 && _SKIP_ON_DUP === true) { $_SESSION['alert'][] = 'info:_SKIP_ON_DUP:'.serialize($sor); continue; } - if ($num == 1) { // update - $v = $vw; - array_shift($v); //$table kivétele - $UPDATE = array(); - for ($i = 0; $i < count($MEZO_LISTA); $i++) { - if ( - $MEZO_LISTA[$i] != '' - and $adatSor[$i] != '' - and !in_array($i,$KULCS_MEZOK) - ) { - if ($adatSor[$i] == '\N') { - array_unshift($UPDATE, "`%s`=NULL"); - array_unshift($v, $MEZO_LISTA[$i]); - } else { - array_unshift($UPDATE, "`%s`='%s'"); - array_unshift($v, $MEZO_LISTA[$i], $adatSor[$i]); - } - } - } - if (count($UPDATE) > 0) { - array_unshift($v, $table); - $q = 'UPDATE `%s` SET '.implode(',',$UPDATE).' WHERE '.implode(' AND ', $where); - $r = db_query($q, array('fv' => 'updateTable/update', 'values' => $v, 'modul' => $db, 'rollback' => true), $lr); - if (!$r) { - db_close($lr); - return false; - } - } - } elseif ($num == 0) { // insert - for ($i = 0; $i < count($MEZO_LISTA); $i++) { - if ($MEZO_LISTA[$i] != '') { - if ($adatSor[$i] == '\N') { - $insertValues[] = 'NULL'; - $insertPatterns[] = '%s'; - } else { - $insertValues[] = $adatSor[$i]; - $insertPatterns[] = "'%s'"; - } - } - } - $q = 'INSERT INTO `%s` ('.implode(',', array_fill(0, count($attrList), '%s')).') - VALUES ('.implode(',', $insertPatterns).')'; - $v = mayor_array_join(array($table), $attrList, $insertValues); - $r = db_query($q, array('fv' => 'updateTable/insert', 'modul' => $db, 'values' => $v, 'rollback' => true), $lr); - if (!$r) { - db_close($lr); - return false; - } - } else { - $_SESSION['alert'][] = 'message:wrong_data:updateTable:több illeszkedő rekord is van, túl laza a kulcs feltétel (' - .call_user_func_array('sprintf', array_merge(array('%s tábla, '.implode(' AND ',$where)), $vw)).')'; - db_rollback($lr); - db_close($lr); - return false; - } - } // while - db_commit($lr); - db_close($lr); - - fclose($fp); - - } - - function generatePDF($outputFile, $outputDir, $str, $booklet=false) { - - - // A szöveg file-ba írása - if (!$fp = fopen($outputDir.'/'.$outputFile.'-u8.tex', 'w')) { - $_SESSION['alert'][] = 'message:file_open_failure:generatePDF:'.$outputDir.'/'.$outputFile.'-u8.tex'; - return false; - } - if (!fwrite($fp, $str)) { - $_SESSION['alert'][] = 'message:file_write_failure:generatePDF:'.$outputDir.'/'.$outputFile.'-u8.tex'; - return false; - } - fclose($fp); - if (__NYOMTATAS_XETEX===true) { - $ret = exec('cd '.$outputDir.'; cat < '.$outputFile.'.tex -%\font\kicsi=ecrm0500 -%\font\nagy=ecbx1200 -%\font\vastag=ecsx0800 -%\font\nagyss=ecsx1200 -%\font\normal=ecss0800 -%\font\dolt=ecsi0800 - -\font\kicsi="Linux Libertine O" at 5pt -\font\nagy="Linux Libertine O/B" at 12pt -\font\nagyss="Arial/B" at 12pt -\font\normal="Linux Biolinum O" at 8pt -\font\dolt="Linux Biolinum O/I" at 8pt -\normal - -EOF -'); - $ret = exec('cd '.$outputDir.'; cat '.$outputFile.'-u8.tex >> '.$outputFile.'.tex'); - $ret = exec('cd '.$outputDir.'; xetex -fmt '._MAYOR_DIR.'/print/module-naplo/xetex/mayor-xetex '.$outputFile.'.tex'); -#ex -fmt '._MAYOR_DIR.'/print/module-naplo/tex/mayor '.$outputFile.'.tex'); - } else { - // utf8 --> cork (t1) - $ret = exec('cd '.$outputDir.'; cat '.$outputFile.'-u8.tex | sed -e "s/\xc2\xa0/\x20/g" | recode u8..T1 > '.$outputFile.'.tex'); - // DVI, PS, PFD generálás (a rotate miatt nem megy a pdftex közvetlenül :o( - $ret = exec('cd '.$outputDir.'; tex -fmt '._MAYOR_DIR.'/print/module-naplo/tex/mayor '.$outputFile.'.tex'); - if ($ret === false) { $_SESSION['alert'][] = 'message:futási_hiba:generatePDF:tex'; return false; } -# LOG $ret = exec('cd '.$outputDir.'; dvips '.$outputFile.'.dvi 2>&1 | tee -a /tmp/x.log '); - $ret = exec('HOME=/tmp && export HOME && cd '.$outputDir.'; dvips '.$outputFile.'.dvi '); - if ($ret === false) { $_SESSION['alert'][] = 'message:futási_hiba:generatePDF:ps'; return false; } - $ret = exec('cd '.$outputDir.'; ps2pdf -sPAPERSIZE=a4 -dAutoRotatePages=/None '.$outputFile.'.ps'); - if (strpos($ret, 'error') !== false) { $_SESSION['alert'][] = 'message:futási_hiba:generatePDF:pdf'; return false; } - - } - if ($booklet) { - $ret = exec('cd '.$outputDir.'; mv '.$outputFile.'.pdf '.$outputFile.'-A4.pdf; pdfbook --short-edge --outfile '.$outputFile.'.pdf '.$outputFile.'-A4.pdf'); - } - return true; - } - - function generateXLS($fileName, $Table, $title) { - - global $policy, $page, $sub, $f; - - if (dirname($fileName) == '.') $fileName = _DOWNLOADDIR."/$policy/$page/$sub/$f/$fileName"; - $fp = fopen($fileName, 'w'); - if (!$fp) { - $_SESSION['alert'][] = 'message:file_open_failure:'.$fileName; - return false; - } - - fputs($fp, ''."\r\n"); - fputs($fp, ''."\r\n"); - fputs($fp, ' '."\r\n" - .' '."\r\n" - .' '."\r\n" - ."\r\n".' '."\r\n"); - - fputs($fp, ''."\r\n"); - fputs($fp, ''."\r\n"); - - for ($i = 0; $i < count($Table); $i++) { - fputs($fp, ' '."\r\n"); - foreach ($Table[$i] as $index => $value) { - if (is_numeric($value)) - fputs($fp, " ".$value."\r\n"); - elseif (strtotime($value)) - if (strlen($value) > 10) { - fputs($fp, " ".str_replace(' ','T',$value).'.000'."\r\n"); - } else { - fputs($fp, " ".$value.'T08:40:00.000'."\r\n"); - } - else - fputs($fp, " ".$value."\r\n"); - } - fputs($fp, ' '."\r\n"); - } - - fputs($fp, '
'."\r\n"); - fputs($fp, '
'."\r\n"); - fputs($fp, '
'."\r\n"); - - fclose($fp); - return true; - - } - - function generateCSV($fileName, $Table, $title, $mezoElvalaszto=' ') { - - global $policy, $page, $sub, $f; - - if (dirname($fileName) == '.') $fileName = _DOWNLOADDIR."/$policy/$page/$sub/$f/$fileName"; - $fp = fopen($fileName, 'w'); - if (!$fp) { - $_SESSION['alert'][] = 'message:file_open_failure:'.$fileName; - return false; - } - - if ($title !='') fputs($fp, $title."\n"); - for ($i = 0; $i < count($Table); $i++) fputs($fp, implode($mezoElvalaszto, $Table[$i])."\n"); - - fclose($fp); - return true; - - } - - function generateODS($fileName, $Table, $title) { - - global $policy, $page, $sub, $f; - - if (dirname($fileName) == '.') $fileName = _DOWNLOADDIR."/$policy/$page/$sub/$f/$fileName"; - define('TMPZIP','/tmp/'.substr(basename($fileName), 0, strpos(basename($fileName), '.'))); - define('ODS_MIMETIPE','application/vnd.oasis.opendocument.spreadsheet'); - define('ODS_MANIFEST',' - - - -'); - define('ODS_START_XMLDOCUMENT',' -'); - define('ODS_ASTYLES',' - - - - - - - - - - - '); - define('ODS_START_SPREADSHEET',''); - define('ODS_START_TABLE',''); - define('ODS_START_ROW',''); - define('ODS_END_ROW',''); - define('ODS_END_TABLE',''); - define('ODS_END_SPREADSHEET',''); - define('ODS_END_XMLDOCUMENT',''); - - $content = ODS_START_XMLDOCUMENT . ODS_ASTYLES . ODS_START_SPREADSHEET . ODS_START_TABLE; - for ($i = 0; $i < count($Table); $i++) { - $content .= ODS_START_ROW; - foreach ($Table[$i] as $index => $value) { - if (is_numeric($value)) - $content .= ''."\n"; - elseif (strtotime($value)) - if (strlen($value) > 10) { - $content .= ''."\n"; - } else { - $content .= ''."\n"; - } - elseif ($value[0] == '=') $content .= ''."\n"; - // formula példa: $value = 'of:=SUM([.A1:.B1])*2+[.A1]' - else $content .= ''.$value.''."\n"; - } - $content .= ODS_END_ROW; - } - $content .= ODS_END_TABLE . ODS_END_SPREADSHEET . ODS_END_XMLDOCUMENT; - - mkdir(TMPZIP); - mkdir(TMPZIP."/META-INF"); - file_put_contents(TMPZIP."/META-INF/manifest.xml", ODS_MANIFEST); - file_put_contents(TMPZIP."/content.xml", $content); - file_put_contents(TMPZIP."/mimetype", ODS_MIMETIPE); - system("cd ".TMPZIP."; zip -mr ".$fileName." mimetype META-INF/* content.xml >/dev/null"); - rmdir(TMPZIP."/META-INF"); - rmdir(TMPZIP); - - return true; - } - -/* --------------------------------------- */ - - function _template2array($fp, $type, &$aTeX) { - $vege = false; - $aTeX[$type] = array(); - while (!$vege && ($sor = fgets($fp, 1024))) { - $sor = chop($sor); - if ($sor == "%}$type") { - $vege = true; - } elseif (substr($sor, 0, 2) != '%!') { // A feldolgozást végző függvény megadása - if (substr($sor, 0, 2) == '%}') { - echo "HIBA #1 Megnyitás előtti blokk lezárás a {$type} blokkban: $sor
"; - } else { - if (substr($sor, 0, 2) == '%{') { - $_type = substr($sor, 2); - _template2array($fp, $_type, $aTeX); - $aTeX[$type][] = '%{'.$_type.'}'; - } else { - // feltételes szövegrészek - $condArray = explode('%?', $sor); - for ($i = 1; $i < count($condArray); $i = $i + 2) { - $str = $condArray[$i]; - $tmpArray = explode('|', $str); - $j = 0; while (is_array($aTeX['conditional']["$j".$tmpArray[0]])) $j++; - $newCondition = "$j".$tmpArray[0]; - $aTeX['conditional'][$newCondition] = array(true => $tmpArray[1], false => $tmpArray[2], 'orig' => $tmpArray[0]); - $sor = str_replace($str.'%?', $newCondition, $sor); - } -// $aTeX[$type][] = $sor; - // lezáró eset - $finalArray = explode('%>', $sor); - for ($i = 1; $i < count($finalArray); $i = $i + 2) { - $str = $finalArray[$i]; - $tmpArray = explode('', $str); - $j = 0; while (is_array($aTeX['finalCase']["$j".$type])) $j++; - $newCondition = "$j".$type; - $aTeX['finalCase'][$newCondition] = array(true => $tmpArray[0], false => $tmpArray[1]); - $sor = str_replace($str.'%>', $newCondition, $sor); - } - $aTeX[$type][] = $sor; - } - } - } - } - } - - function _array2text($type, $id, $mit, $mire, $aTeX, $ADAT, $flag = null) { - $ret = ''; - if (is_null($id)) $A = $ADAT[$type]; - else $A = $ADAT[$type][$id]; - - // A cserélendő attribútumok - if (is_array($A)) foreach ($A as $attr => $value) { - if (!is_array($value)) { - if (true || !is_bool($value)) { // feltételes szövegrészek külön kezelendők ??? Miért is? Az általánosabb feltételes kiíráshoz kell! - if (in_array('%$'.$attr, $mit)) { // A már szereplő mintát felülírjuk! - $key = array_search('%$'.$attr, $mit); - $mit[$key] = '%$'.$attr; - $mire[$key] = $value; - } else { - $mit[] = '%$'.$attr; - $mire[] = $value; - } - } - } - } - - // aTeX feldolgozása - $TeX = $aTeX[$type]; - for ($i = 0; $i < count($TeX); $i++) { - $sor = $TeX[$i]; - if (substr($sor, 0, 2) == '%{') { - // Almodul feldolgozása - $_type = substr($sor, 2, -1); - if (is_array($A[$_type])) { - if (is_null($id)) { - foreach ($A[$_type] as $key => $_id) $ret .= _array2text($_type, $_id, $mit, $mire, $aTeX, $ADAT); - } else { - $count = count($A[$_type]); $db = 0; - foreach ($A[$_type] as $_id => $_data) { - $db++; if ($count == $db) $_flag = 'final'; else $_flag = null; - if (!is_array($ADAT[$_type][$_id]) && !is_array($_data)) { - echo '
HIBA#2!!! '.$_type.':'.$_id.':'.$_data.'
'; -// return false; - } else { - if (!is_array($ADAT[$_type][$_id])) $ADAT[$_type][$_id] = array(); - elseif (!is_array($_data)) $_data = array(); - $ADAT[$_type][$_id] = $ADAT[$_type][$_id] + $_data; - $ret .= _array2text($_type, $_id, $mit, $mire, $aTeX, $ADAT, $_flag); - } - } - } - } elseif (__DEBUG === true) { echo '
HIBA#3: '.$sor.'
'.$_type.':'; var_dump($A[$_type]); echo '
';} - } else { - // Csere - lezáró eset - if (strpos($sor, '%>') !== false) foreach ($aTeX['finalCase'] as $attr => $values) { - $sor = str_replace('%>'.$attr, $values[ $flag === 'final' ], $sor); - } - // Csete - feltételes kiírás - if (strpos($sor, '%?') !== false) foreach ($aTeX['conditional'] as $attr => $values) { - // Nem csak az adott szintről veszi az értéket, hanem feljebbről is (a feljebbi a meghatározó - ez nem biztos, hogy jó...) - if ($key = array_search('%$'.$values['orig'], $mit)) $_val = $mire[$key]; - else $_val = $A[$values['orig']]; - $sor = str_replace('%?'.$attr, $values[ $_val==true ], $sor); - //$sor = str_replace('%?'.$attr, $values[ $A[$values['orig']]==true ], $sor); - } - // Kiírás - $ret .= str_replace($mit, $mire, $sor)."\n"; - } - } - - return $ret; - } - - function template2text($templateFile, $ADAT) { - - $mit = $mire = array(); - $aTeX = array('conditional' => array()); - - $fp = fopen($templateFile, 'r'); - _template2array($fp, 'base', $aTeX); - fclose($fp); - return _array2text('base', null, $mit, $mire, $aTeX, $ADAT); - - } - - function template2file($templateFile, $ADAT) { - - global $policy, $page, $sub, $f; - - $mit = $mire = array(); - $aTeX = array('conditional' => array()); - - $fp = fopen($templateFile, 'r'); - // A feldolgozást végző függvény neve - $sor = fgets($fp, 1024); - rewind($fp); - if (substr($sor, 0, 2) == '%!') { - list($func,$ext,$opt) = explode(' ', substr(chop($sor), 2)); - if (!function_exists($func)) unset($func); - } - if ($ext=='') $ext = 'txt'; - _template2array($fp, 'base', $aTeX); - fclose($fp); - $text = _array2text('base', null, $mit, $mire, $aTeX, $ADAT); -//die(); - if ($text === false) return false; - $success = true; - if (isset($func)) { - $success = $func($text, $ADAT['file'], $opt); - } else { - $fp = fopen(_DOWNLOADDIR."/$policy/$page/$sub/$f/".$ADAT['file'].'.'.$ext, 'w'); - fputs($fp, $text); - fclose($fp); - } - if ($success) return $ADAT['file'].".$ext"; - else return false; - - } - - - -?> -- cgit v1.2.3