mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 10:37:39 -07:00
delete user package
This commit is contained in:
parent
06c7b42204
commit
25a2926881
2 changed files with 70 additions and 0 deletions
54
bin/v_delete_user_package
Executable file
54
bin/v_delete_user_package
Executable 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
|
16
web/delete/package/index.php
Normal file
16
web/delete/package/index.php
Normal 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/");
|
Loading…
Add table
Add a link
Reference in a new issue