Created
October 16, 2017 05:35
-
-
Save lezsakdomi/7c5a5ada16b30914b42d283664303065 to your computer and use it in GitHub Desktop.
mayor docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
if [ "$MAYORDIR" = "" ]; then echo "A MAYORDIR változó üres. Kilépek."; exit 1; fi | |
PWGEN=`which pwgen` | |
if [ "${PWGEN}" = "" ]; then echo "A pwgen szoftver nincs telepítve."; exit 1; fi | |
echo "Konfigurációs állományok létrehozása:" | |
for file in main-config.php parent-conf.php private-conf.php public-conf.php | |
do | |
if [ -e "${MAYORDIR}/config/${file}" ]; then echo " $file létezik."; else | |
echo -n " $file.example --> " | |
PW=`pwgen -s1` | |
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` | |
PWREAD=`pwgen -s1` | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
if [ "$MAYORDIR" = "" ]; then echo "MAYORDIR változó üres. Kilépek!"; exit 1; fi | |
echo -n "Config fileok ellenőrzése..." | |
if [ ! -e "$MAYORDIR/log" ]; then mkdir $MAYORDIR/log; fi | |
if [ ! -e /var/log/mayor ]; then ln -s $MAYORDIR/log /var/log/mayor; fi | |
if [ ! -e /etc/mayor ]; then ln -s $MAYORDIR/config /etc/mayor; fi | |
chmod +x $MAYORDIR/bin/mayor | |
FILES="$MAYORDIR/config/parent-conf.php $MAYORDIR/config/private-conf.php $MAYORDIR/config/main-config.php $MAYORDIR/config/module-naplo/config.php $MAYORDIR/install/base/mysql/mayor-login.sql $MAYORDIR/install/base/mysql/mayor-auth.sql $MAYORDIR/install/base/mysql/private-users.sql $MAYORDIR/install/module-naplo/mysql/naplo-users.sql" | |
for f in $FILES | |
do | |
if [ ! -e $f ]; then echo -e "\n\r Nincs meg a szükséges ${f} config file!"; exit 1; else echo -n '.'; fi | |
done; | |
echo " kész."; | |
if [ ! -e $MAYORDIR/log/mayor-base.rev ]; then | |
echo " Hiányzó mayor-base.rev file"; | |
if [ -e $MAYORDIR/log/revision ]; | |
then | |
IREV=`cat $MAYORDIR/log/revision` | |
else | |
IREV=""; | |
fi | |
else | |
cp $MAYORDIR/log/mayor-base.rev $MAYORDIR/log/revision | |
IREV=`cat $MAYORDIR/log/revision` | |
fi | |
echo " Az aktuális revision: ${IREV}" | |
if [ "$IREV" = "" ] | |
then | |
echo " Nincs revision file és helyreállítani sem tudom. Kilépek!" | |
exit 1; | |
fi | |
echo " SQL fileok létrehozása... " | |
mkdir -p $TMPDIR/mysql | |
cd $TMPDIR/mysql | |
DB=`grep db $MAYORDIR/config/main-config.php | sed -e "s/$.*=\ *['|\"]//g" -e "s/['|\"];//g"` | |
USER=`grep user $MAYORDIR/config/main-config.php | sed -e "s/$.*=\ *['|\"]//g" -e "s/['|\"];//g"` | |
PW=`grep pw $MAYORDIR/config/main-config.php | sed -e "s/$.*=\ *['|\"]//g" -e "s/['|\"];//g"` | |
cat $MAYORDIR/install/base/mysql/mayor-login.sql | sed -e "s/%MYSQL_LOGIN_DB%/$DB/g" -e "s/%MYSQL_LOGIN_USER%/$USER/g" \ | |
-e "s/%MYSQL_LOGIN_PW%/$PW/g" > 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://wiki.mayor.hu/doku.php?id=hogyan:telepites#operacios_rendszer_telepitese | |
FROM debian:jessie | |
# http://wiki.mayor.hu/doku.php?id=hogyan:telepites-debian#a_etc_apt_sourceslist_kiegeszitese | |
# Not neccessary for Ubuntu | |
RUN sed -i 's/deb \([^ ][^ ]*\) \([^ ][^ ]*\) main/deb \1 \2 main contrib non-free/g' /etc/apt/sources.list | |
# http://wiki.mayor.hu/doku.php?id=hogyan:telepites-man#az_elso_inditas_utan | |
RUN apt-get update \ | |
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | |
apache2 \ | |
php5 php5-mysql php5-ldap \ | |
mysql-server \ | |
recode \ | |
texlive texlive-plain-extra texlive-fonts-extra texlive-fonts-recommended texlive-lang-hungarian texlive-latex-extra cm-super \ | |
texlive-xetex ttf-mscorefonts-installer \ | |
ghostscript \ | |
ntp \ | |
wget \ | |
ssl-cert \ | |
ssh \ | |
&& rm -r /var/lib/apt/lists/* | |
RUN apt-get update \ | |
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | |
pwgen \ | |
supervisor \ | |
&& rm -r /var/lib/apt/lists/* | |
#CMD ["/sbin/init"] | |
#RUN systemctl enable apache2 | |
#EXPOSE 80 | |
#RUN systemctl enable mysql | |
CMD ["/usr/bin/supervisord"] | |
RUN mkdir -p /var/log/supervisor | |
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | |
EXPOSE 80 | |
# http://wiki.mayor.hu/doku.php?id=hogyan:telepites-man#mayor_rendszer_telepitese | |
ARG php_memory_limit=256M | |
RUN sed -i "s/memory_limit/memory_limit = $php_memory_limit ; old value: /" /etc/php5/apache2/php.ini | |
ADD virtualhost.conf /etc/apache2/sites-available/mayor.conf | |
RUN a2dissite 000-default && a2ensite mayor | |
#RUN service apache2 reload | |
ENV TMPDIR="/tmp" | |
ARG VERSION="current" | |
RUN mkdir -p "$TMPDIR" \ | |
&& wget "http://www.mayor.hu/download/current/mayor-base-$VERSION.tgz" -O "$TMPDIR/mayor-base.tgz" \ | |
&& wget "http://www.mayor.hu/download/current/mayor-naplo-$VERSION.tgz" -O "$TMPDIR/mayor-naplo.tgz" | |
ARG PREFIX="/var" | |
ARG INSTALLDIR="mayor" | |
ENV MAYORDIR="$PREFIX/$INSTALLDIR" | |
RUN mkdir -p "$MAYORDIR" \ | |
&& tar -xzf "$TMPDIR/mayor-base.tgz" -C "$MAYORDIR" \ | |
&& tar -xzf "$TMPDIR/mayor-naplo.tgz" -C "$MAYORDIR" \ | |
&& rm "$TMPDIR/mayor-base.tgz" "$TMPDIR/mayor-naplo.tgz" | |
RUN sed -i "s#/var/mayor#$MAYORDIR#g" /etc/apache2/sites-available/mayor.conf | |
#RUN service apache2 reload | |
RUN cp "$MAYORDIR/install/base/mysql/utf8.cnf" /etc/mysql/conf.d/utf8.cnf | |
#RUN service mysql restart | |
# http://wiki.mayor.hu/doku.php?id=hogyan:telepites-man#karbantartast_segito_szkriptek | |
RUN ln -s "$MAYORDIR/bin/mayor" "/usr/local/sbin" | |
RUN ln -s "$MAYORDIR/bin/etc/cron.daily/mayor" "/etc/cron.daily" | |
RUN cp "$MAYORDIR/config/main.conf.example" "$MAYORDIR/config/main.conf" | |
RUN chown -R "$(bash -c 'source /etc/apache2/envvars && echo $APACHE_RUN_GROUP')" "$MAYORDIR/config/" \ | |
&& chmod 700 "$MAYORDIR/config/" \ | |
&& chown root "$MAYORDIR/config/main.conf" \ | |
&& chmod 600 "$MAYORDIR/config/main.conf" | |
# http://wiki.mayor.hu/doku.php?id=hogyan:telepites-man#szimbolikus_linkek_es_jogosultsagok | |
RUN if [ -e "$MAYORDIR/download" ]; then \ | |
chown -R "$(bash -c 'source /etc/apache2/envvars && echo $APACHE_RUN_GROUP')" "$MAYORDIR/download"; \ | |
fi && if [ -e "$MAYORDIR/www/wiki/conf" ]; then \ | |
chown -R "$(bash -c 'source /etc/apache2/envvars && echo $APACHE_RUN_GROUP')" "$MAYORDIR/www/wiki/conf"; \ | |
fi && if [ -e "$MAYORDIR/www/wiki/data" ]; then \ | |
chown -R "$(bash -c 'source /etc/apache2/envvars && echo $APACHE_RUN_GROUP')" "$MAYORDIR/www/wiki/data"; \ | |
fi | |
ADD linker.sh linker.sh | |
RUN ./linker.sh && rm ./linker.sh | |
# Create mayor.fmt according to install.d/55tex.sh from http://www.mayor.hu/download/current/mayor-installer-rev4208.tgz | |
RUN ( \ | |
cd "$MAYORDIR/print/module-naplo/tex/" \ | |
&& fmtutil-sys --cnffile "$MAYORDIR/print/module-naplo/tex/mayor.cnf" --fmtdir "$MAYORDIR/print/module-naplo/" --byfmt mayor \ | |
&& if [ -e "$MAYORDIR/print/module-naplo/mayor.fmt" ]; then mv "$MAYORDIR/print/module-naplo/mayor.fmt" "$MAYORDIR/print/module-naplo/tex/mayor.fmt"; fi \ | |
) && ( \ | |
cd "$MAYORDIR/print/module-naplo/xetex/" \ | |
&& fmtutil-sys --cnffile "$MAYORDIR/print/module-naplo/xetex/mayor-xetex.cnf" --fmtdir "$MAYORDIR/print/module-naplo/" --byfmt mayor-xetex \ | |
) | |
# Modified install.d/15createconfig.sh from http://www.mayor.hu/download/current/mayor-installer-rev4208.tgz | |
ADD createconfig.sh createconfig.sh | |
RUN ./createconfig.sh && rm createconfig.sh | |
# Improved http://wiki.mayor.hu/doku.php?id=hogyan:telepites-man#mysql_beallitasa | |
ADD createsqls.sh createsqls.sh | |
RUN ./createsqls.sh && rm createsqls.sh | |
ARG MYSQL_ROOT_PASSWORD | |
ENV MYSQLROOTPW="${MYSQL_ROOT_PASSWORD:-root}" | |
RUN service mysql start \ | |
&& mysqladmin -u root password "$MYSQLROOTPW" \ | |
&& service mysql stop | |
ADD importsql.sh importsql.sh | |
RUN ./importsql.sh \ | |
"$TMPDIR/mysql/mayor-login.sql" \ | |
"$TMPDIR/mysql/mayor-parent.sql" \ | |
"$TMPDIR/mysql/mayor-private.sql" \ | |
"$TMPDIR/mysql/base.sql" \ | |
"$TMPDIR/mysql/private-users.sql" \ | |
"$TMPDIR/mysql/naplo-users.sql" \ | |
&& rm importsql.sh | |
## https://certbot.eff.org/#debianjessie-apache | |
#RUN echo "deb http://ftp.debian.org/debian jessie-backports main" >>/etc/apt/sources.list | |
#RUN apt-get update \ | |
# && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends -t jessie-backports \ | |
# certbot \ | |
# && rm -r /var/lib/apt/lists/* | |
#RUN certbot --apache | |
# http://wiki.mayor.hu/doku.php?id=hogyan:telepites-man#az_apache_web-szerver_beallitasai | |
ARG HOSTNAME | |
RUN a2enmod ssl \ | |
&& mkdir /etc/apache2/ssl \ | |
&& (echo "${HOSTNAME:-localhost}"; echo "") | make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem \ | |
&& sed -i -e 's/\*:80/\*:443/' -e 's/#\(SSL.*\)/\1/' /etc/apache2/sites-available/mayor.conf | |
EXPOSE 443 | |
RUN a2enmod rewrite \ | |
&& a2ensite 000-default \ | |
&& sed -i '/<\/VirtualHost>/i\ | |
\ RewriteEngine On\n\ | |
\ RewriteRule (.*)$ https://%{SERVER_NAME}/$1 [L]' \ | |
/etc/apache2/sites-available/000-default.conf | |
RUN sed -i -e "s/#\?\(ServerName \).*/\1$HOSTNAME/" /etc/apache2/sites-available/mayor.conf | |
RUN sed -i -e "s/#\?\(ServerName \).*/\1$HOSTNAME/" /etc/apache2/sites-available/mayor.conf \ | |
&& echo "ServerName $HOSTNAME" >>/etc/apache2/apache2.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
service mysql start | |
trap "service mysql stop" EXIT | |
for f in "$@"; do | |
echo -n "Importing $f... " | |
cat "$f" | mysql -u "root" -p"$MYSQLROOTPW" --default-character-set=utf8 | |
ret=$? | |
if [ $ret == 0 ]; then | |
echo "done" | |
else | |
exit $ret | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source $MAYORDIR/update/linkme.sh | |
POLICIES="parent public" | |
BASEDIR="$MAYORDIR" | |
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 || exit 255 | |
else | |
echo " [OK] A könyvtár már létezik: $MAYORDIR/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 || exit 255 | |
else | |
echo " Hiányzó file: $BASEDIR/www/policy/private/$file" >&2 | |
#exit 255 | |
fi | |
else | |
echo " [OK] A file már létezik: $BASEDIR/www/policy/private/$file" | |
fi | |
done | |
done | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[supervisord] | |
nodaemon=true | |
[program:apache2] | |
command=/usr/sbin/apache2ctl -DFOREGROUND | |
[program:mysql] | |
command=/usr/bin/pidproxy /var/run/mysqld/mysqld.pid /usr/bin/mysqld_safe --pid-file=/var/run/mysqld/mysqld.pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerName localhost | |
ServerAdmin webmaster@localhost | |
#SSLEngine On | |
#SSLCertificateFile /etc/apache2/ssl/apache.pem | |
DocumentRoot /var/mayor/www/ | |
<Directory /> | |
Options FollowSymLinks | |
AllowOverride None | |
</Directory> | |
<Directory /var/mayor/www/> | |
Options -Indexes +FollowSymLinks +MultiViews | |
AllowOverride None | |
# Apache 2.2 # Order allow,deny | |
# Apache 2.2 # allow from all | |
# Apache 2.4 # Require all granted | |
<IfVersion >= 2.3> | |
Require all granted | |
</IfVersion> | |
<IfVersion < 2.3> | |
order allow,deny | |
allow from all | |
</IfVersion> | |
#RewriteEngine On | |
#RewriteBase / | |
#RewriteCond %{SERVER_PORT} ^80$ | |
#RewriteCond %{THE_REQUEST} .*(policy=private|page=auth|page=password).* | |
#RewriteRule (.*)$ https://%{SERVER_NAME}/$1 [L] | |
</Directory> | |
ErrorLog /var/log/apache2/error.log | |
# Possible values include: debug, info, notice, warn, error, crit, | |
# alert, emerg. | |
LogLevel warn | |
CustomLog /var/log/apache2/access.log combined | |
ServerSignature On | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment