Skip to content

Commit 25a2926

Browse files
committed
delete user package
1 parent 06c7b42 commit 25a2926

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

bin/v_delete_user_package

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
# info: delete user package
3+
# options: package
4+
#
5+
# The function for deleting user package. It does not allow to delete pacakge
6+
# if it is in use.
7+
8+
9+
#----------------------------------------------------------#
10+
# Variable&Function #
11+
#----------------------------------------------------------#
12+
13+
# Argument defenition
14+
package=$1
15+
16+
# Includes
17+
source $VESTA/conf/vesta.conf
18+
source $VESTA/func/main.sh
19+
20+
# Functions
21+
is_package_in_use() {
22+
check_package=$(grep "PACKAGE='$package'" $USER_DATA/*/user.conf)
23+
if [ ! -z "$check_package" ]; then
24+
echo "Error: package $package is in use"
25+
log_event "$E_INUSE" "$EVENT"
26+
exit $E_INUSE
27+
fi
28+
}
29+
30+
#----------------------------------------------------------#
31+
# Verifications #
32+
#----------------------------------------------------------#
33+
34+
check_args '1' "$#" 'package'
35+
validate_format 'package'
36+
is_package_valid
37+
is_package_in_use
38+
39+
40+
#----------------------------------------------------------#
41+
# Action #
42+
#----------------------------------------------------------#
43+
44+
# Deleting user package
45+
rm -f $VESTA/data/packages/$package.pkg
46+
47+
48+
#----------------------------------------------------------#
49+
# Vesta #
50+
#----------------------------------------------------------#
51+
52+
log_event "$OK" "$EVENT"
53+
54+
exit

web/delete/package/index.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
// Init
3+
error_reporting(NULL);
4+
ob_start();
5+
session_start();
6+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
7+
8+
if ($_SESSION['user'] == 'admin') {
9+
if (!empty($_GET['package'])) {
10+
$v_package = escapeshellarg($_GET['package']);
11+
exec (VESTA_CMD."v_delete_user_package ".$v_package, $output, $return_var);
12+
unset($output);
13+
}
14+
}
15+
16+
header("Location: /list/package/");

0 commit comments

Comments
 (0)