freenetis-addresses-github/install.sh @ master
ec7a7d3d | david | #!/bin/bash
|
|
8aa82b90 | david | #
|
|
# This file is part of open source system FreenetIS
|
|||
# and it is released under GPLv3 licence.
|
|||
#
|
|||
# More info about licence can be found:
|
|||
# http://www.gnu.org/licenses/gpl-3.0.html
|
|||
#
|
|||
# More info about project can be found:
|
|||
# http://www.freenetis.org/
|
|||
#
|
|||
#
|
|||
ec7a7d3d | david | set -e
|
|
if [ "$(id -u)" != "0" ]; then
|
|||
echo "This script must be run as root" 1>&2
|
|||
exit 1
|
|||
fi
|
|||
5898e047 | David Raška | if [[ "$1" == "-u" ]];
|
|
ec7a7d3d | david | then
|
|
5898e047 | David Raška | echo "Uninstalling"
|
|
rm -rf /var/www/freenetis-addresses
|
|||
rm -f /etc/freenetis-addresses.ini
|
|||
exit 1
|
|||
ec7a7d3d | david | fi
|
|
5898e047 | David Raška | if [ ! -r /etc/freenetis-addresses.ini ]
|
|
ec7a7d3d | david | then
|
|
5898e047 | David Raška | # get user name
|
|
while [ true ]
|
|||
do
|
|||
read -p "DB user name: " user
|
|||
ec7a7d3d | david | ||
5898e047 | David Raška | if [ -n "$user" ]
|
|
then
|
|||
break
|
|||
fi
|
|||
done
|
|||
# get password
|
|||
read -sp "DB user password: " pass
|
|||
echo
|
|||
# get server
|
|||
read -p "DB server (default localhost): " server
|
|||
if [ -z "$server" ]
|
|||
then
|
|||
server="localhost"
|
|||
fi
|
|||
# get port
|
|||
read -p "DB port (default 3306): " port
|
|||
if [ -z "$port" ]
|
|||
then
|
|||
port="3306"
|
|||
fi
|
|||
ec7a7d3d | david | ||
5898e047 | David Raška | # get database
|
|
read -p "DB database (default addresses): " db
|
|||
ec7a7d3d | david | ||
5898e047 | David Raška | if [ -z "$db" ]
|
|
then
|
|||
db="addresses"
|
|||
fi
|
|||
echo "Saving configuration"
|
|||
# save configuration
|
|||
echo mysql_user=$user > /etc/freenetis-addresses.ini
|
|||
echo mysql_pass=$pass >> /etc/freenetis-addresses.ini
|
|||
echo mysql_server=$server >> /etc/freenetis-addresses.ini
|
|||
echo mysql_port=$port >> /etc/freenetis-addresses.ini
|
|||
echo mysql_db=$db >> /etc/freenetis-addresses.ini
|
|||
fi
|
|||
ec7a7d3d | david | ||
echo "Installing"
|
|||
# install
|
|||
5898e047 | David Raška | rm -rf /var/www/freenetis-addresses
|
|
ec7a7d3d | david | mkdir /var/www/freenetis-addresses
|
|
cp ./index.php /var/www/freenetis-addresses/
|
|||
cp ./import.sh /var/www/freenetis-addresses/
|
|||
chmod 700 /var/www/freenetis-addresses/import.sh
|
|||
# configure CRON
|
|||
echo "Preparing CRON"
|
|||
echo "# /etc/cron.d/freenetis-addresses: Regular CRON file for freenetis-addressses (triggered each day)" > /etc/cron.d/freenetis-addresses
|
|||
echo "" >> /etc/cron.d/freenetis-addresses
|
|||
echo "SHELL=/bin/bash" >> /etc/cron.d/freenetis-addresses
|
|||
02314c07 | David Raška | echo $(shuf -i 0-59 -n 1) $(shuf -i 0-23 -n 1) "* * * root /var/www/freenetis-addresses/import.sh --cron >>\"/var/log/freenetis-addresses.log\" 2>&1" >> /etc/cron.d/freenetis-addresses
|
|
ec7a7d3d | david | ||
if [ -x /usr/sbin/invoke-rc.d ]; then
|
|||
invoke-rc.d cron restart 3>/dev/null || true
|
|||
else
|
|||
/etc/init.d/cron restart 3>/dev/null || true
|
|||
fi
|
|||
exit 0
|