# !/bin/sh
baseDirname=`dirname $0`/
Absolute=$(cd $(dirname $0); pwd)

cd $Absolute
cp  $Absolute"/default" /etc/nginx/sites-available/default
mkdir /usr/nginx
cp -r $Absolute"/dist"  /usr/nginx/
nginx -s reload
cp  $Absolute"/nginx.service" /usr/lib/systemd/
systemctl enable nginx.service
systemctl restart nginx.service
cp ${Absolute}"/mariadb.cnf" /etc/mysql/mariadb.cnf
systemctl restart mysql
mysql_root_pwd="jumple"
mysql_cnf_path="/etc/mysql/my.cnf"
export mysql_passwd=$mysql_root_pwd
echo ""
echo ""
mysql -uroot mysql ls<<EOF
EOF

if [ $? -eq 0 ]; then
echo ""
echo ""
else
echo "-"
mysql -uroot -p'jumple'<< EOF
flush privileges;
alter user 'root'@'localhost' identified by 'jumple';
create database pns character set utf8;
flush privileges;
EOF
if [ $? -eq 0 ]; then
echo "---"
echo "-----"
else
echo "-------"
fi
fi
cd $Absolute"/pns"
./pnsd -i

