1
0
mirror of https://github.com/myvesta/vesta.git synced 2025-03-11 03:52:44 -07:00
myvesta/bin/v-check-vesta-license

64 lines
1.8 KiB
Plaintext
Raw Permalink Normal View History

2015-11-02 15:28:16 +02:00
#!/bin/bash
# info: check vesta license
# options: [MODULE]
#
# The function activates and register vesta license
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
2015-11-06 17:38:58 +02:00
# Argument definition
2015-11-02 15:28:16 +02:00
module=$(echo $1 | tr '[:lower:]' '[:upper:]')
2015-11-06 17:38:58 +02:00
# Importing system environment
2015-11-02 15:28:16 +02:00
source /etc/profile
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Checking module
if [ -z "$module" ]; then
modules=$(grep _KEY= $VESTA/conf/vesta.conf)
else
modules=$(grep "${module}_KEY" $VESTA/conf/vesta.conf)
fi
IFS=$'\n'
for str in $modules; do
module=$(echo "$str" |cut -f 1 -d _)
license=$(echo "$str" |cut -f 2 -d \')
if [ ! -z "$license" ]; then
v_host='https://vestacp.com/checkout'
answer=$(curl --max-time 60 -s "$v_host/check.php?licence_key=$license&module=$module")
2015-11-02 15:28:16 +02:00
check_result $? "cant' connect to vestacp.com " 0
2015-11-03 00:58:39 +02:00
echo "$module $license $answer"
2015-11-02 15:28:16 +02:00
if [[ "$answer" != '0' ]]; then
2015-11-03 00:58:39 +02:00
if [ "$module" = 'SFTPJAIL' ]; then
setsid $BIN/v-delete-sys-sftp-jail 2>/dev/null
fi
sed -i "s/${module}_KEY=.*/${module}_KEY=''/g" \
$VESTA/conf/vesta.conf
2015-11-02 15:28:16 +02:00
fi
fi
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit