Fix openvpn scripts connections to mysql and french comments
This commit is contained in:
parent
94b401abc7
commit
59e514d77c
@ -183,6 +183,10 @@ printf "\n################## Setup web application ##################\n"
|
||||
cp -r "$base_path/installation/scripts" "/etc/openvpn/"
|
||||
chmod +x "/etc/openvpn/scripts/"*
|
||||
|
||||
# Configure MySQL in openvpn scripts
|
||||
sed -i "s/\$user='';/\$user='$mysql_user';/" "/etc/openvpn/scripts/config.sh"
|
||||
sed -i "s/\$pass='';/\$pass='$mysql_pass';/" "/etc/openvpn/scripts/config.sh"
|
||||
|
||||
# Create the directory of the web application
|
||||
mkdir "$openvpn_admin"
|
||||
cp -r "$base_path/"{index.php,sql,bower.json,.bowerrc,js,include,css,installation/client-conf} "$openvpn_admin"
|
||||
|
@ -1,11 +1,8 @@
|
||||
#!/bin/bash
|
||||
# Serveur
|
||||
|
||||
# MySQL credentials
|
||||
HOST='localhost'
|
||||
# Port (par défaut : 3306)
|
||||
PORT='3306'
|
||||
# Username
|
||||
USER='vpn_user'
|
||||
# Password
|
||||
PASS='mdp'
|
||||
# Nom de la base de données
|
||||
DB='vpn'
|
||||
USER=''
|
||||
PASS=''
|
||||
DB='openvpn-admin'
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
. /etc/openvpn/scripts/config.sh
|
||||
|
||||
# On insert les données dans la table de log
|
||||
# We insert data in the log table
|
||||
mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -e "INSERT INTO log (log_id, user_id, log_trusted_ip, log_trusted_port, log_remote_ip, log_remote_port, log_start_time, log_end_time, log_received, log_send) VALUES(NULL, '$common_name','$trusted_ip', '$trusted_port','$ifconfig_pool_remote_ip', '$remote_port_1', now(),'0000-00-00 00:00:00', '$bytes_received', '$bytes_sent')"
|
||||
|
||||
# On spécifie que l'utilisateur est en ligne
|
||||
mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -e "UPDATE user SET user_online=1 WHERE user_id='$common_name'"
|
||||
# We specify that the user is online
|
||||
mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -e "UPDATE user SET user_online=1 WHERE user_id='$common_name'"
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
. /etc/openvpn/scripts/config.sh
|
||||
|
||||
# On précise que l'utilisateur n'est plus en ligne
|
||||
# We specify the user is offline
|
||||
mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -e "UPDATE user SET user_online=0 WHERE user_id='$common_name'"
|
||||
|
||||
# On insert le datetime de déconnexion
|
||||
mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -e "UPDATE log SET log_end_time=now(), log_received='$bytes_received', log_send='$bytes_sent' WHERE log_trusted_ip='$trusted_ip' AND log_trusted_port='$trusted_port' AND user_id='$common_name' AND log_end_time='0000-00-00 00:00:00'"
|
||||
# We insert the deconnection datetime
|
||||
mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -e "UPDATE log SET log_end_time=now(), log_received='$bytes_received', log_send='$bytes_sent' WHERE log_trusted_ip='$trusted_ip' AND log_trusted_port='$trusted_port' AND user_id='$common_name' AND log_end_time='0000-00-00 00:00:00'"
|
||||
|
@ -4,5 +4,5 @@
|
||||
# Authentication
|
||||
user_id=$(mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -sN -e "SELECT user_id FROM user WHERE user_id = '$username' AND user_pass = SHA1('$password') AND user_enable=1 AND (TO_DAYS(now()) >= TO_DAYS(user_start_date) OR user_start_date='0000-00-00') AND (TO_DAYS(now()) <= TO_DAYS(user_end_date) OR user_end_date='0000-00-00')")
|
||||
|
||||
# Vérification de l'utilisateur
|
||||
[ "$user_id" != '' ] && [ "$user_id" = "$username" ] && echo "user : $username" && echo 'authentication ok.' && exit 0 || echo 'authentication failed.'; exit 1
|
||||
# Check the user
|
||||
[ "$user_id" != '' ] && [ "$user_id" = "$username" ] && echo "user : $username" && echo 'authentication ok.' && exit 0 || echo 'authentication failed.'; exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user