OSDN Git Service

a7e4e79e75a0e6a6c6656d4472bf8e8868a2c618
[lxcf/lxcf.git] / lxcf / lib / lxcf-queue-cancel
1 #!/bin/sh
2
3 # LXCF - LXC Facility
4 # copyright (C) 2014 FUJITSU LIMITED All Rights Reserved
5
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
9 # of the License.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
19 # 02110-1301, USA.
20
21 LOGFILE="/var/log/lxcf/lxcf-messages"
22
23 # check root
24 if [ ${EUID:-${UID}} != 0 ]; then
25     echo "error: Because you are not root, you cannot execute this command. "
26     exit 1
27 fi
28
29 # check args
30 if [ $# -ne 1 ]; then
31         echo "usage: lxcf queue cancel UU-ID"
32         exit 1
33 fi
34
35 UUID=$1
36
37 LINE=`cat /var/tmp/lxcf/*queue | egrep "^$UUID"`
38
39 if [ $? -eq 1 ]; then
40   echo "error: uuid" $UUID "is not exist"
41   exit -1
42 fi
43
44 cancel_queue() {
45         flock $1 sed -i "/^$UUID/d" $1
46 }
47
48 TM=`LANG=C date +"%c"`
49
50 cancel_queue  /var/tmp/lxcf/hqueue
51 cancel_queue  /var/tmp/lxcf/qqueue
52 cancel_queue  /var/tmp/lxcf/lqueue
53
54 flock $LOGFILE echo "###" $TM "CANCELED :" $LINE "###" >> $LOGFILE 
55
56 echo "Canceled :" $LINE
57
58 exit 0