delete user package

This commit is contained in:
Serghey Rodin 2012-07-31 15:32:26 +03:00
commit 25a2926881
2 changed files with 70 additions and 0 deletions

54
bin/v_delete_user_package Executable file
View file

@ -0,0 +1,54 @@
#!/bin/bash
# info: delete user package
# options: package
#
# The function for deleting user package. It does not allow to delete pacakge
# if it is in use.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
package=$1
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
# Functions
is_package_in_use() {
check_package=$(grep "PACKAGE='$package'" $USER_DATA/*/user.conf)
if [ ! -z "$check_package" ]; then
echo "Error: package $package is in use"
log_event "$E_INUSE" "$EVENT"
exit $E_INUSE
fi
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'package'
validate_format 'package'
is_package_valid
is_package_in_use
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Deleting user package
rm -f $VESTA/data/packages/$package.pkg
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
log_event "$OK" "$EVENT"
exit

View file

@ -0,0 +1,16 @@
<?php
// Init
error_reporting(NULL);
ob_start();
session_start();
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
if ($_SESSION['user'] == 'admin') {
if (!empty($_GET['package'])) {
$v_package = escapeshellarg($_GET['package']);
exec (VESTA_CMD."v_delete_user_package ".$v_package, $output, $return_var);
unset($output);
}
}
header("Location: /list/package/");