PyLoad setup

cd ~/compile
rm -r ~/compile/pyload
unzip pyload-src-v0.4.9.zip
cd ~/compile/pyload
find . -type f \( -exec sed -i s/"\/usr\/bin\/perl"/"\/ffp\/bin\/perl"/g {} \; , -exec sed -i s/"\/usr\/bin\/python"/"\/ffp\/bin\/python"/g {} \; , -exec sed -i s/"\/usr\/bin\/bash"/"\/ffp\/bin\/bash"/g {} \; , -exec sed -i s/"\/usr\/bin\/sh"/"\/ffp\/bin\/sh"/g {} \; , -exec sed -i s/"\/usr\/bin\/env"/"\/ffp\/bin\/env"/g {} \; , -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/g {} \; , -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/g {} \; , -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/g {} \; , -exec sed -i s/"\/ffp\/ffp\/"/"\/ffp\/"/g {} \; \)

#Modify /ffp/home/root/.pyload/pyload.conf:
#str prefix : "Path Prefix" = /pyload
#for proxypass do: 
#bool https : "Use HTTPS" = False

#grep -m1 -r -i -I "src='\/" .
#grep -m1 -r -i -I "src=\"\/" .
find . -type f ! -name "*.py" -exec sed -i s/"src='\/"/"src='\/pyload\/"/g {} \;
find . -type f ! -name "*.py" -exec sed -i s/"src=\"\/"/"src=\"\/pyload\/"/g {} \;

#grep -m1 -r -i -I "href='\/" .
#grep -m1 -r -i -I "href=\"\/" .
find . -type f ! -name "*.py" -exec sed -i s/"href='\/"/"href='\/pyload\/"/g {} \;
find . -type f ! -name "*.py" -exec sed -i s/"href=\"\/"/"href=\"\/pyload\/"/g {} \;

#grep -r -i -I "'\/media\/" .
#grep -r -i -I "\"\/media\/" .
#grep -r -i -I "url(\/templates\/" .
find . -type f ! -name "*.py" ! -name "*.conf" -exec sed -i s/"'\/media\/"/"'\/pyload\/media\/"/g {} \;
find . -type f ! -name "*.py" ! -name "*.conf" -exec sed -i s/"\"\/media\/"/"\"\/pyload\/media\/"/g {} \;
find . -type f ! -name "*.py" -exec sed -i s/"url(\/templates\/"/"url(\/pyload\/templates\/"/g {} \;
find . -type f ! -name "*.py" -exec sed -i s/"\"\/pathchooser"/"\"\/pyload\/pathchooser"/g {} \;

#grep -r -i -I "'\/json\/" .
#grep -r -i -I "\"\/json\/" .
find . -type f ! -name "*.py" -exec sed -i s/"\"\/json\/"/"\"\/pyload\/json\/"/g {} \;
find . -type f ! -name "*.py" -exec sed -i s/"'\/json\/"/"'\/pyload\/json\/"/g {} \;

#grep -r -I "'\/api\/" .
#grep -r -I "\"\/api\/" .
find . -type f ! -name "*.py" -exec sed -i s/"'\/api\/"/"'\/pyload\/api\/"/g {} \;
find . -type f ! -name "*.py" -exec sed -i s/"\"\/api\/"/"\"\/pyload\/api\/"/g {} \;

#grep -r -i -I "redirect(\"\/" .
find . -type f -name "*.py" -exec sed -i s/"redirect(\"\/\")"/"redirect(\"\/pyload\/home\")"/g {} \;
find . -type f -name "*.py" -exec sed -i s/"redirect(\"\/login\")"/"redirect(\"\/pyload\/login\")"/g {} \;
find . -type f -name "*.py" -exec sed -i s/"redirect(\"\/nopermission\")"/"redirect(\"\/pyload\/nopermission\")"/g {} \;
find . -type f -name "*.py" -exec sed -i s/"redirect(\"\/setup\")"/"redirect(\"\/pyload\/setup\")"/g {} \;

AliasMatch /pyload/(media|templates)/(.+)$ /ffp/opt/pyload/module/web/$1/$2
<DirectoryMatch "/ffp/opt/pyload/module/web/(media|templates)">
	Header set X-UA-Compatible "IE=edge"
	Order allow,deny
	Allow from all
</DirectoryMatch>

<Location /pyload/>
	ProxyPass						http://127.0.0.1:8000/pyload/
	ProxyPassReverse				http://127.0.0.1:8000/pyload/
	ProxyPassReverseCookieDomain	127.0.0.1		adrhc.go.ro
</Location>
#end: prepare to proxypass

#Modify /ffp/opt/pyload/module/web/templates/default/base.html by adding favicon.ico from http://pyload.org/:
#

#manage user
python /ffp/opt/pyload/pyLoadCore.py -u

#Force rebuilding of *.py:
find /ffp/opt/pyload/module/web -name "*.pyc" -exec rm {} \;

rm -r /ffp/opt/pyload/
cp -r ../pyload /ffp/opt/
cd /ffp/opt/pyload/

Compiling leptonica 1.69

#configuration for new package:
NEW_BUILD_NAME=leptonica
NEW_BUILD_VER=1.69
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0
cd ~/compile/
wget https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz
tar xvzf $NEW_BUILD_NAME_AND_VER.tar.gz
cd ~/compile/$NEW_BUILD_NAME_AND_VER/
find . -type f \( -exec sed -i s/"\/usr\/bin\/perl"/"\/ffp\/bin\/perl"/ {} \; , -exec sed -i s/"\/usr\/bin\/python"/"\/ffp\/bin\/python"/ {} \; , -exec sed -i s/"\/usr\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/usr\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/usr\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/ffp\/ffp\/"/"\/ffp\/"/ {} \; \)
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -pthread -O2 -lintl -Wall -I/ffp/include"
export LDFLAGS="-L/ffp/lib -lintl"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
./configure --help > configure.help.txt 
./configure --prefix=/ffp
make
#new package creation & installation
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -i ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz
funpkg -q $NEW_BUILD_NAME

Compiling tesseract-ocr 3.02.02

#configuration for new package:
NEW_BUILD_NAME=tesseract-ocr
NEW_BUILD_VER=3.02.02
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0
cd ~/compile/
wget https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz
tar xvzf $NEW_BUILD_NAME_AND_VER.tar.gz
cd ~/compile/$NEW_BUILD_NAME_AND_VER/
find . -type f \( -exec sed -i s/"\/usr\/bin\/perl"/"\/ffp\/bin\/perl"/ {} \; , -exec sed -i s/"\/usr\/bin\/python"/"\/ffp\/bin\/python"/ {} \; , -exec sed -i s/"\/usr\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/usr\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/usr\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/ffp\/ffp\/"/"\/ffp\/"/ {} \; \)
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -pthread -O2 -lintl -Wall -I/ffp/include"
export LDFLAGS="-L/ffp/lib -lintl"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
./autogen.sh
./configure --help > configure.help.txt 
export LIBLEPT_HEADERSDIR=/ffp/include
./configure --prefix=/ffp
nohup /ffp/bin/make -C ~/compile/tesseract-ocr &
renice -14 `pidof cc1plus` -p `pidof make` -p `pidof as`
tail -f nohup.out
#new package creation & installation
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -i ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz
funpkg -q $NEW_BUILD_NAME

Compiling libev-4.19

#configuration for new package:
NEW_BUILD_NAME=libev
NEW_BUILD_VER=4.19
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0
cd ~/compile/
wget http://dist.schmorp.de/libev/libev-4.19.tar.gz
tar xvzf $NEW_BUILD_NAME_AND_VER.tar.gz
cd ~/compile/$NEW_BUILD_NAME_AND_VER/
find . -type f \( -exec sed -i s/"\/usr\/bin\/perl"/"\/ffp\/bin\/perl"/ {} \; , -exec sed -i s/"\/usr\/bin\/python"/"\/ffp\/bin\/python"/ {} \; , -exec sed -i s/"\/usr\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/usr\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/usr\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/ffp\/ffp\/"/"\/ffp\/"/ {} \; \)
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -pthread -O2 -lintl -Wall -I/ffp/include"
export LDFLAGS="-L/ffp/lib -lintl"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
./configure --help > configure.help.txt 
./configure --prefix=/ffp
make
#new package creation & installation
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -i ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz
funpkg -q $NEW_BUILD_NAME

Compiling nspr-4.10.7

cd ~/compile/
wget http://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v4.10.7/src/nspr-4.10.7.tar.gz
tar xvzf nspr-4.10.7.tar.gz
cd ~/compile/nspr-4.10.7/nspr
find . -type f \( -exec sed -i s/"\/usr\/bin\/perl"/"\/ffp\/bin\/perl"/ {} \; , -exec sed -i s/"\/usr\/bin\/python"/"\/ffp\/bin\/python"/ {} \; , -exec sed -i s/"\/usr\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/usr\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/usr\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/ffp\/ffp\/"/"\/ffp\/"/ {} \; \)
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -pthread -O2 -lintl -Wall -I/ffp/include"
export LDFLAGS="-L/ffp/lib -lintl"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
./configure --prefix=/ffp --enable-strip --with-arm-kuser --with-pthreads
make
#configuration for new package:
NEW_BUILD_NAME=nspr
NEW_BUILD_VER=4.10.7
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0
#new package creation & installation
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -i ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz
funpkg -q $NEW_BUILD_NAME

Python 2.7.9

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

#Compiling python-2.7.9
NEW_BUILD_NAME=python
NEW_BUILD_VER=2.7.9
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

#ERROR
	Failed to build these modules:
	_curses_panel      readline
#SOLUTION (before configure)
	use -lreadline -lncurses for BUILD_FLAGS and LDFLAGS
#./configure --prefix=/ffp --enable-shared --enable-ipv6 --enable-big-digits --enable-unicode --with-signal-module --with-threads=/ffp --with-pth --with-doc-strings --without-pymalloc --with-fpectl --with-ensurepip=upgrade
#configure without pip; better install manually pip-6.0.6 in order to avoid CERTIFICATE_VERIFY_FAILED error when running pip
./configure --prefix=/ffp --enable-shared --enable-ipv6 --enable-big-digits --enable-unicode --with-signal-module --with-threads=/ffp --with-pth --with-doc-strings --without-pymalloc --with-fpectl
#ERROR
	./Parser/asdl_c.py -h Include ./Parser/Python.asdl
	/ram_bin/usr/bin/python: /ffp/lib/libpthread.so.0: no version information available (required by /usr/lib/libpython2.6.so.1.0)
	make: *** [Include/Python-ast.h] Segmentation fault (core dumped)
#SOLUTION (before make)
	touch Include/Python-ast.h Python/Python-ast.c
#ERROR
	Failed to build these modules:
	_curses_panel
#SOLUTION (before make)
	slacker -u br2:ncurses-5.9_20140927-arm-1.txz
renice -14 `pidof cc1plus` -p `pidof make` -p `pidof as` -p `pidof configure`
#grep -I -r "\/bin" . | grep -v "\/ffp\/bin" | grep -v "\/ffp\/sbin"
sed -i s/"\/bin\/install"/"\/ffp\/bin\/install"/g Makefile
sed -i s/"\/bin\/install"/"\/ffp\/bin\/install"/g Makefile.pre
touch Include/Python-ast.h Python/Python-ast.c
nohup /ffp/bin/make -C ~/compile/Python-2.7.9 &
tail -f nohup.out
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz
#In order to avoid CERTIFICATE_VERIFY_FAILED when using easy_install (from setuptools)
#download the Mozilla's CA Bundle certificate:
wget -nv http://curl.haxx.se/ca/cacert.pem -O /ffp/etc/ssl/cert.pem

#You could use easy_install (from setuptools module) in order to install modules as alternative to pip.
#When using pip if required to use --egg option than better compile the module manually.
#see http://forum.nas-central.org/viewtopic.php?f=249&t=16627&p=92309#p92309

#List python modules:
python
#then, from python's shell/prompt:
help('modules')
help('setuptools') -> info about setuptools module
help('jinja2') -> info about jinja2 module (observe lower case usage)

#List module's files
pip show -f Jinja2

#Install pip 6.0.6 (a tool for installing and managing Python packages)
#pip 6.0.6 has no CERTIFICATE_VERIFY_FAILED error
#requires scripttest (>=1.3) and virtualenv (>=1.10)
#wget https://pypi.python.org/packages/source/s/scripttest/scripttest-1.3.tar.gz
#wget https://pypi.python.org/packages/source/v/virtualenv/virtualenv-12.0.5.tar.gz#md5=637abbbd04d270ee8c601ab29c4f7561
cd ~/compile
wget https://pypi.python.org/packages/source/p/pip/pip-6.0.6.tar.gz#md5=bbb17814bdf82187f46aaf9cec6b6caa
tar xvzf pip-6.0.6.tar.gz
cd pip-6.0.6
~/x.sh ffpg
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -fno-stack-protector -pthread -O2 -Wall -I/ffp/include"
export LDFLAGS="-L/ffp/lib"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
python setup.py --help-commands
python setup.py --help
python setup.py --help build
python setup.py build
python setup.py install --record module-files.txt

#Uninstall a python module
cd ~/compile/pip-1.2.1 -> has CERTIFICATE_VERIFY_FAILED error at install
cd ~/compile/pip-1.5.6 -> has CERTIFICATE_VERIFY_FAILED error always
cd ~/compile/pip-6.0.6 -> has no CERTIFICATE_VERIFY_FAILED error
cat module-files.txt | xargs rm -rf
find /ffp/lib/python2.7/ -name "*pip*"
rm -r /ffp/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg

#Install Jinja2-2.7.3
cd ~/compile
wget https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz
tar xvzf Jinja2-2.7.3.tar.gz
cd Jinja2-2.7.3
find . -type f \( -exec sed -i s/"\/usr\/bin\/perl"/"\/ffp\/bin\/perl"/ {} \; , -exec sed -i s/"\/usr\/bin\/python"/"\/ffp\/bin\/python"/ {} \; , -exec sed -i s/"\/usr\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/usr\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/usr\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/ffp\/ffp\/"/"\/ffp\/"/ {} \; \)
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -pthread -O2 -lintl -Wall -I/ffp/include"
export LDFLAGS="-L/ffp/lib -lintl"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
python setup.py --help-commands
python setup.py --help
python setup.py --help build
python setup.py build
python setup.py install --record module-files.txt

#Install SCons (better compile manually SCons because its files have non-FFP paths)
#SCons install doesn't work without --egg option.
#see also http://forum.nas-central.org/viewtopic.php?f=249&t=16627&p=92309#p92309
pip install -U setuptools
pip install SCons -vvv --egg --log /ffp/var/log/python/SCons.txt
#Modify the paths used by /ffp/bin/scons* files.

#Using pip:
python -m pip help
python -m pip list
#varianta cu freeze e o listare care arata si eventualele probleme ale pachetelor
python -m pip freeze
python -m pip help install
python -m pip search simplejson
python -m pip install simplejson -> nu a functionat
python -m pip install cryptography 0.6.1
python -m pip install pyOpenSSL 0.14 -vvv --log /ffp/var/log/python/pyOpenSSL-0.14.txt
python -m pip list --outdated
python -m pip install -U CherryPy -> updating CherryPy
python -m pip uninstall pycurl
python -m pip install rst2html5 -> required by aria2
pip install PIL --allow-unverified PIL

#ERROR (la instalarea multor pachete)
	AttributeError: Distribution instance has no attribute 'include_package_data'
#SOLUTION
	Nu instala setuptools folosind:
	wget https://bitbucket.org/pypa/setuptools/get/default.tar.gz#egg=setuptools-dev

#Install setuptools 7.0
cd ~/compile
#wget imediat urmator va crapa dar va afisa wget pt descarcarea setuptools 7.0 ce functioneaza corect:
#wget https://bootstrap.pypa.io/ez_setup.py -O - | python
#setuptools 7.0 ce functioneaza corect:
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.zip
mv default.tar.gz setuptools-7.0.tar.gz
cd pypa-setuptools-48a23a037ea2/
find . -type f \( -exec sed -i s/"\/usr\/bin\/perl"/"\/ffp\/bin\/perl"/ {} \; , -exec sed -i s/"\/usr\/bin\/python"/"\/ffp\/bin\/python"/ {} \; , -exec sed -i s/"\/usr\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/usr\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/usr\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/ffp\/ffp\/"/"\/ffp\/"/ {} \; \)
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -pthread -O2 -lintl -Wall -I/ffp/include"
export LDFLAGS="-L/ffp/lib -lintl"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
python setup.py --help-commands
python setup.py --help
python setup.py --help build
python setup.py build
python setup.py install --record module-files.txt

#Install pycurl-7.19.5 -> required by pyLoad and easier to install using pip or easy_install (from setuptools)
cd ~/compile
wget http://pycurl.sourceforge.net/download/pycurl-7.19.5.tar.gz
tar xvzf pycurl-7.19.5.tar.gz
cd pycurl-7.19.5
find . -type f \( -exec sed -i s/"\/usr\/bin\/perl"/"\/ffp\/bin\/perl"/ {} \; , -exec sed -i s/"\/usr\/bin\/python"/"\/ffp\/bin\/python"/ {} \; , -exec sed -i s/"\/usr\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/usr\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/usr\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/ffp\/ffp\/"/"\/ffp\/"/ {} \; \)
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -pthread -O2 -lintl -Wall -I/ffp/include"
export LDFLAGS="-L/ffp/lib -lintl"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
python setup.py --help-commands
python setup.py --help
#ERROR0
	python: symbol 'CRYPTO_set_locking_callback': can't resolve symbol
	python: symbol 'CRYPTO_num_locks': can't resolve symbol
	python: symbol 'CRYPTO_set_id_callback': can't resolve symbol
	Traceback (most recent call last):
	File "<stdin>", line 1, in <module>
	ImportError: unknown dlopen() error
#SOLUTION0
	Nu compila cu openssl:
	python setup.py build --curl-config=/ffp/bin/curl-config --with-ssl --openssl-dir=/ffp
	Modifica setup.py:
	# self.libraries = []
	self.libraries = ["crypto"]
python setup.py build --curl-config=/ffp/bin/curl-config --with-ssl
python setup.py install --record module-files.txt
#test installation:
python
import pycurl
CTRL+D

#certifi (14.5.14)	-> required in order to avoid CERTIFICATE_VERIFY_FAILED when using easy_install (from setuptools)
#pip (6.0.6)		-> required version in order to avoid CERTIFICATE_VERIFY_FAILED error when running pip

#Requirements files are used to hold the result from pip freeze for the purpose of achieving repeatable installations. 
#In this case, your requirement file contains a pinned version of everything that was installed when pip freeze was run.
pip freeze > /ffp/opt/apache-htdocs/public/python2.7-packages.txt
pip install -r /ffp/opt/apache-htdocs/public/python2.7-packages.txt

#ecdsa module below must be corrected after installation:
cd /ffp/lib/python2.7/site-packages/ecdsa
ffpg

#root@nsa310:~# pip list
certifi (14.5.14)
CherryPy (3.2.6)
ecdsa (0.12)
iotop (0.6)
Jinja2 (2.7.3)
libxml2-python (2.6.21)
lxml (3.4.2)
MarkupSafe (0.23)
mod-python (3.5.0-)
nose (1.3.4)
paramiko (1.15.2)
pip (6.0.6)
pycrypto (2.6.1)
pycurl (7.19.5.1)
pykg-config (1.3.0)
Pyrex (0.9.9)
pysqlite (2.6.3)
pytesseract (0.1.5)
pytz (2014.10)
setuptools (12.0.4)
tzselect (0.1)
WebHelpers (1.3)

Tomcat datasource in context.xml

<Resource name="exifweb"
		  auth="Container"
		  type="javax.sql.DataSource"
		  factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
		  testWhileIdle="true"
		  testOnBorrow="true"
		  testOnReturn="false"
		  validationQuery="SELECT 1"
		  validationInterval="30000"
		  timeBetweenEvictionRunsMillis="30000"
		  maxActive="10"
		  minIdle="2"
		  maxIdle="3"
		  maxWait="5000"
		  initialSize="1"
		  removeAbandonedTimeout="60"
		  removeAbandoned="false"
		  logAbandoned="false"
		  minEvictableIdleTimeMillis="30000"
		  jmxEnabled="false"
		  jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState"
		  username="exifweb"
		  password="exifweb"
		  driverClassName="com.mysql.jdbc.Driver"
		  url="jdbc:mysql://localhost:3306/exifweb"/>

MetaRepository from mijzelf

cd /i-data/md0/admin/zy-pkgs
wget http://downloads.zyxel.nas-central.org/Users/Mijzelf/zypkg-repo/MetaRepository_20140529_arm_010.zpkg
cd ~/temp
wget http://downloads.zyxel.nas-central.org/Users/Mijzelf/zypkg-repo/ZYPKGS
#copy MetaRepository from ~/temp/ZYPKGS within /i-data/md0/admin/zy-pkgs/ZYPKGS
#web_prefix: insert as first line "http://downloads.zyxel.nas-central.org/Users/Mijzelf/zypkg-repo/NSA310/4.70/zypkg/"
cd /usr/local/zy-pkgs/zypkg_conf
touch status
touch /i-data/md0/admin/zy-pkgs/ZYPKGS 
touch /i-data/md0/admin/zy-pkgs/web_prefix 
#go to Firmware/Packages (only press Package tab, don't Retrieve List From Internet)
#install & start MetaRepository
#notice the new page:
#http://192.168.1.31:82/pkg/MetaRepository/pkgcgi.cgi
#wait 5s
#press Retrieve List From Internet button

#Help for tools:
#http://zyxel.nas-central.org/wiki/3rd_party_zypkgs#Tweaks

Compiling xorg util-macros-1.19.0

cd ~/compile/
rm -r ~/compile/util-macros-1.19.0
mkdir util-macros-1.19.0
cd ~/compile/util-macros-1.19.0
git clone -q -b util-macros-1.19.0 git://anongit.freedesktop.org/xorg/util/macros
mv -v macros/* .
rm -r macros
find . -type f \( -exec sed -i s/"\/usr\/bin\/perl"/"\/ffp\/bin\/perl"/ {} \; , -exec sed -i s/"\/usr\/bin\/python"/"\/ffp\/bin\/python"/ {} \; , -exec sed -i s/"\/usr\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/usr\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/usr\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/ffp\/ffp\/"/"\/ffp\/"/ {} \; \)
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -pthread -O2 -lintl -Wall -I/ffp/include"
export LDFLAGS="-L/ffp/lib -lintl"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
./autogen.sh --prefix=/ffp
./configure --help > configure.help.txt
./configure --prefix=/ffp
rm -r $HOME/temp/util-macros-1.19.0
make install DESTDIR=$HOME/temp/util-macros-1.19.0
cd $HOME/temp/util-macros-1.19.0
ls -l /tmp/util-maceos-*
ls -l ~/ffp_0.7_armv5/packages/util-maceos-*
makepkg util-macros 1.19.0 0
mv -v /tmp/util-maceos-* ~/ffp_0.7_armv5/packages

Compiling m4-1.4.17

cd ~/compile/
wget http://ftp.gnu.org/gnu/m4/m4-1.4.17.tar.gz
tar xvzf m4-1.4.17.tar.gz
cd ~/compile/m4-1.4.17
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -fno-stack-protector -pthread -O2 -Wall -I/ffp/include -I/ffp/opt/apache-2.2.29-worker/include"
export LDFLAGS="-L/ffp/lib"
export LDFLAGS="-L/ffp/lib -lintl -lpthread"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
./configure --prefix=/ffp --enable-dependency-tracking --enable-threads=posix --with-libsigsegv-prefix=/ffp --disable-assert --enable-c++ --enable-changeword --with-syscmd-shell=/ffp/bin/sh
make
rm -r $HOME/temp/m4-1.4.17
make install DESTDIR=$HOME/temp/m4-1.4.17
cd $HOME/temp/m4-1.4.17
ls -l /tmp/m4-*
ls -l ~/ffp_0.7_armv5/packages/m4-*
makepkg m4 1.4.17 0
cp -v /tmp/m4-1.4.17-arm-0.txz ~/ffp_0.7_armv5/packages/
funpkg -i ~/ffp_0.7_armv5/packages/m4-1.4.17-arm-0.txz

Compiling libgd 2.1.0

export BUILD_FLAGS="-march=armv5te -pthread -O2 -lintl -Wall -DNDEBUG -DLINUX -I/ffp/include"
export LDFLAGS="-L/ffp/lib -lintl"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX

cd ~/compile/libgd-2.1.0

ERROR1:
	ceva cu ceill (atentie, sunt 2x l la final)
SOLUTION:
	find . -name gd_bmp.c -exec sed -i s/"ceill"/"ceil"/ {} \;

./configure --prefix=/ffp --with-libiconv-prefix=/ffp --with-zlib=/ffp --with-png=/ffp --with-freetype=/ffp --with-fontconfig=/ffp --with-jpeg=/ffp --with-tiff=/ffp
~/x.sh ffpg
nohup /ffp/bin/make -C ~/compile/libgd-2.1.0 &


#~/x.sh ffpg
find . -type f ! -name "*.txt" \( \
        -exec sed -i s/"\/bin\/arch"/"\/ffp\/bin\/arch"/g {} \; , \
        -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/g {} \; , \
        -exec sed -i s/"\/bin\/cc"/"\/ffp\/bin\/cc"/g {} \; , \
        -exec sed -i s/"\/bin\/chmod"/"\/ffp\/bin\/chmod"/g {} \; , \
        -exec sed -i s/"\/bin\/date"/"\/ffp\/bin\/date"/g {} \; , \
        -exec sed -i s/"\/bin\/echo"/"\/ffp\/bin\/echo"/g {} \; , \
        -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/g {} \; , \
        -exec sed -i s/"\/bin\/file"/"\/ffp\/bin\/file"/g {} \; , \
        -exec sed -i s/"\/bin\/install"/"\/ffp\/bin\/install"/g {} \; , \
        -exec sed -i s/"\/bin\/ln"/"\/ffp\/bin\/ln"/g {} \; , \
        -exec sed -i s/"\/bin\/ls"/"\/ffp\/bin\/ls"/g {} \; , \
        -exec sed -i s/"\/bin\/pwd"/"\/ffp\/bin\/pwd"/g {} \; , \
        -exec sed -i s/"\/bin\/sed"/"\/ffp\/bin\/sed"/g {} \; , \
        -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/g {} \; , \
        -exec sed -i s/"\/bin\/tr"/"\/ffp\/bin\/tr"/g {} \; , \
        -exec sed -i s/"\/bin\/uname"/"\/ffp\/bin\/uname"/g {} \; , \
        -exec sed -i s/"\/sbin\/install"/"\/ffp\/bin\/install"/g {} \; , \
        -exec sed -i s/"\/sbin\/ldconfig"/"\/ffp\/sbin\/ldconfig"/g {} \; , \
        -exec sed -i s/"\/sbin\/sysctl"/"\/ffp\/sbin\/sysctl"/g {} \; , \
        -exec sed -i s/"\/sbin\/\$sysctl"/"\/ffp\/sbin\/\$sysctl"/g {} \; , \
        -exec sed -i s/"\/usr\/bin"/"\/ffp\/bin"/g {} \; , \
        -exec sed -i s/"\/usr\/include"/"\/ffp\/include"/g {} \; , \
        -exec sed -i s/"\/usr\/lib"/"\/ffp\/lib"/g {} \; , \
        -exec sed -i s/"\/usr\/local"/"\/ffp"/g {} \; , \
        -exec sed -i s/"\/usr\/make"/"\/ffp\/bin\/make"/g {} \; , \
        -exec sed -i s/"\/usr\/sbin\/install"/"\/ffp\/bin\/install"/g {} \; , \
        -exec sed -i s/"\/usr\/sbin\/lsattr"/"\/ffp\/bin\/lsattr"/g {} \; , \
        -exec sed -i s/"\/usr\/sbin\/lsdev"/"\/ffp\/bin\/lsdev"/g {} \; , \
        -exec sed -i s/"\/usr\/sbin\/sysctl"/"\/ffp\/sbin\/sysctl"/g {} \; , \
        -exec sed -i s/"\/usr\/sbin\/\$sysctl"/"\/ffp\/sbin\/\$sysctl"/g {} \; , \
        -exec sed -i s/"\/usr\/ffp"/"\/ffp"/g {} \; , \
        -exec sed -i s/"\/ffp\/ffp"/"\/ffp"/g {} \; \
    \)

Compiling MySql 5.6.21

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

cd $HOME/compile
rm -r $HOME/compile/mysql-5.6.21
tar -xzvf mysql-5.6.21.tar.gz
cd $HOME/compile/mysql-5.6.21
~/x.sh ffpg

NEW_BUILD_NAME=mysql
NEW_BUILD_VER=5.6.21
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

#CMakeCache.txt:
CMAKE_BUILD_TYPE:STRING=RELEASE
//Flags used by the compiler during all build types.
CMAKE_CXX_FLAGS:STRING='-I/ffp/include '
//Flags used by the compiler during release builds.
CMAKE_CXX_FLAGS_RELEASE:STRING=-O2 -DNDEBUG
//Flags used by the compiler during all build types.
CMAKE_C_FLAGS:STRING='-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -pthread -O2 -lintl -Wall -DNDEBUG -DLINUX -I/ffp/include'
//Flags used by the compiler during release builds.
CMAKE_C_FLAGS_RELEASE:STRING=-O2 -DNDEBUG
//Flags used by the linker.
CMAKE_EXE_LINKER_FLAGS:STRING= -L/ffp/lib -lintl
//Enable/Disable output of compile commands during generation.
CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON
CMAKE_INSTALL_PREFIX:PATH=/ffp
//Flags used by the linker during the creation of modules.
CMAKE_MODULE_LINKER_FLAGS:STRING= -L/ffp/lib -lintl
//Flags used by the linker during the creation of dll's.
CMAKE_SHARED_LINKER_FLAGS:STRING= -L/ffp/lib -lintl
CMAKE_VERBOSE_MAKEFILE:BOOL=ON
ENABLE_DEBUG_SYNC:BOOL=OFF
FEATURE_SET:STRING=large
MYSQL_DATADIR:PATH=/ffp/opt/srv/mysql/datadir
SYSCONFDIR:PATH=/ffp/etc
TMPDIR:PATH=/ffp/opt/srv/mysql/tmp
WITHOUT_PARTITION_STORAGE_ENGINE:BOOL=ON
WITH_DEBUG:BOOL=OFF
#WITH_SSL=/ffp
HAVE_FINITE:INTERNAL=TRUE
HAVE_FINITE_IN_MATH_H:INTERNAL=1
HAVE_LLVM_LIBCPP:INTERNAL=1
 
#all params with help text
#cmake . -LAH > cmake.help.txt
#interactive display
ccmake . -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_CXX_FLAGS="$BUILD_FLAGS" -DCMAKE_CXX_FLAGS_RELEASE="$BUILD_FLAGS" -DCMAKE_C_FLAGS="$BUILD_FLAGS" -DCMAKE_C_FLAGS_RELEASE="$BUILD_FLAGS" -DCMAKE_EXE_LINKER_FLAGS="-L/ffp/lib -lintl" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=/ffp -DCMAKE_MODULE_LINKER_FLAGS="-L/ffp/lib -lintl" -DCMAKE_SHARED_LINKER_FLAGS="-L/ffp/lib -lintl" -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_DEBUG_SYNC=OFF -DFEATURE_SET=large -DMYSQL_DATADIR=/ffp/opt/srv/mysql/data -DSYSCONFDIR=/ffp/etc -DTMPDIR=/ffp/opt/srv/mysql/tmp -DWITH_DEBUG=0 -DHAVE_FINITE=TRUE -DHAVE_FINITE_IN_MATH_H=1
ccmake . -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/ffp -DFEATURE_SET=large
#Attention, after any CMakeCache.txt modification run again configure (press c) from ccmake gui.
#After running configure verify that HAVE_FINITE:INTERNAL=TRUE, HAVE_FINITE_IN_MATH_H:INTERNAL=1 and HAVE_LLVM_LIBCPP:INTERNAL=1.
#Then run generate (press g).

nohup /ffp/bin/make -C ~/compile/mysql-5.6.21 &
 
#MAKEPKG:
rm -r $HOME/temp/mysql-5.6.21
make install DESTDIR=$HOME/temp/mysql-5.6.21
cd $HOME/temp/mysql-5.6.21
find . -type f \( -exec sed -i s/"\/usr\/bin\/perl"/"\/ffp\/bin\/perl"/ {} \; , -exec sed -i s/"\/usr\/bin\/python"/"\/ffp\/bin\/python"/ {} \; , -exec sed -i s/"\/usr\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/usr\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/usr\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/ffp\/ffp\/"/"\/ffp\/"/ {} \; \)
ls -l /tmp/mysql-*
ls -l ~/ffp_0.7_armv5/packages/mysql-*
makepkg mysql 5.6.21 0
 
#INSTALL & CONFIGURE
funpkg -i /$HOME/ffp_0.7_armv5/packages/mysql-5.6.21-arm-1.txz
#sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES	-> specific to mysql 5.6.x
sed -i s/"#sql_mode"/"sql_mode"/ /ffp/etc/my.cnf

#CREATE SYSTEM DB (first step and mandatory before using mysql)
export SRVPATH=/ffp/opt/srv
mkdir -p $SRVPATH/mysql/innodb/
mkdir -p $SRVPATH/mysql/innodblogdir/
mkdir -p $SRVPATH/mysql/binlog/
mkdir -p $SRVPATH/mysql/log/
mkdir -p $SRVPATH/mysql/tmp/
mkdir -p $SRVPATH/mysql/data
chmod -R 777 $SRVPATH
cd /ffp
scripts/mysql_install_db --user=root --datadir=/ffp/opt/srv/mysql/data
cd ~ && /ffp/start/mysqld.sh start
mysql -p -> the default password is nothing
UPDATE mysql.user SET Password = PASSWORD('xxx321') WHERE User = 'root';
GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'xxx321' WITH GRANT OPTION;
FLUSH PRIVILEGES;
#mysqladmin -u root password "xxx321"

#RESTORE BDs
cp /i-data/md0/seagate-ext4/ProjectsNew/nsa310-config/trunk/mysql-db-design/*.sql.gz $HOME/temp/mysql-restore
cd $HOME/temp/mysql-restore
gunzip exifweb.sql.gz
gunzip wordpress.sql.gz
gunzip owncloud702.sql.gz
gunzip ghost.sql.gz
gunzip pydio.sql.gz
ls -l *.sql
 
mysql -p
CREATE DATABASE exifweb CHARACTER SET utf8;
CREATE DATABASE wordpress CHARACTER SET utf8;
CREATE DATABASE owncloud702 CHARACTER SET utf8;
CREATE DATABASE ghost CHARACTER SET utf8;
CREATE DATABASE pydio CHARACTER SET utf8;
GRANT ALL ON exifweb.* TO 'exifweb'@'%' IDENTIFIED BY 'exifweb' WITH GRANT OPTION;
GRANT ALL ON wordpress.* TO 'wordpress'@'%' IDENTIFIED BY 'wordpress' WITH GRANT OPTION;
GRANT ALL ON owncloud702.* TO 'owncloud702'@'%' IDENTIFIED BY 'owncloud702' WITH GRANT OPTION;
GRANT ALL ON ghost.* TO 'ghost'@'%' IDENTIFIED BY 'ghost' WITH GRANT OPTION;
GRANT ALL ON pydio.* TO 'pydio'@'%' IDENTIFIED BY 'pydio' WITH GRANT OPTION;
FLUSH PRIVILEGES;
 
mysql -u root -p exifweb < exifweb.sql
mysql -u root -p wordpress < wordpress.sql
mysql -u root -p owncloud702 < owncloud702.sql
mysql -u root -p ghost < ghost.sql
mysql -u root -p pydio < pydio.sql
chmod -R 777 $SRVPATH

#UPGRADE DB schema
#If you use InnoDB, consider setting innodb_fast_shutdown to 0 before shutting down and upgrading your server.
/ffp/start/mysqld.sh stop
sed -i s/"innodb_fast_shutdown\s*=\s*1"/"innodb_fast_shutdown = 0"/ /ffp/etc/my.cnf
grep innodb_fast_shutdown /ffp/etc/my.cnf
/ffp/start/mysqld.sh start
/ffp/start/mysqld.sh stop
/ffp/start/mysqld.sh start
mysql_upgrade -u root -p --socket=/ffp/var/run/mysql/mysql.sock -v
/ffp/start/mysqld.sh stop
sed -i s/"innodb_fast_shutdown\s*=\s*0"/"innodb_fast_shutdown = 1"/ /ffp/etc/my.cnf
grep innodb_fast_shutdown /ffp/etc/my.cnf
/ffp/start/mysqld.sh start

Install & configure pydio

cd $HOME

#database
mysql -p
CREATE DATABASE pydio CHARACTER SET utf8;
GRANT ALL ON pydio.* TO 'pydio'@'%' IDENTIFIED BY 'pydio' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

cd /i-data/60cb70cf/www/pages/
wget http://sourceforge.net/projects/ajaxplorer/files/pydio/stable-channel/5.2.5/pydio-core-5.2.5.tar.gz/download
tar -xzvf pydio-core-5.2.5.tar.gz
cd pydio-core-5.2.5

#go to https://adrhc.go.ro/pydio/
./x.sh hstop
#modify pydio-core-5.2.5/conf/bootstrap_context.php:
define("AJXP_FORCE_LOGPATH", "/ffp/var/log/ajaxplorer/");
define("AJXP_DATA_PATH", "/mnt/HD_a2/www/pages/pydiocore5.2.5-data");
mv data ../pydiocore5.2.5-data
chown -R nobody:nobody /i-data/60cb70cf/www/pages/pydiocore5.2.5-data
chmod -R 755 /i-data/60cb70cf/www/pages/pydiocore5.2.5-data
./x.sh hstart

#go to https://adrhc.go.ro/pydio/ and start installation wizard