diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2016-07-17 17:57:15 +0300 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2016-07-17 23:50:51 +0300 |
commit | 187f09be5b81c5682dd45745f309775c77199b98 (patch) | |
tree | 0d28e38eb2978fa1163317d6d3c7e4eb2b024124 | |
parent | 20407dfd6bb00e9c3459a5d84720a20899c0a381 (diff) | |
download | awall-187f09be5b81c5682dd45745f309775c77199b98.tar.bz2 awall-187f09be5b81c5682dd45745f309775c77199b98.tar.xz |
exit with 0 if policy already enabled/disabled
-rw-r--r-- | awall/policy.lua | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/awall/policy.lua b/awall/policy.lua index 8ad87db..27e8400 100644 --- a/awall/policy.lua +++ b/awall/policy.lua @@ -1,6 +1,6 @@ --[[ Policy file handling for Alpine Wall -Copyright (C) 2012-2014 Kaarle Ritvanen +Copyright (C) 2012-2016 Kaarle Ritvanen See LICENSE file for license details ]]-- @@ -14,6 +14,7 @@ local contains = util.contains local keys = util.keys local listpairs = util.listpairs local map = util.map +local printmsg = util.printmsg local json = require('cjson') @@ -85,14 +86,14 @@ end function Policy:enable() self:checkoptional() - if self.enabled then raise('Policy already enabled: '..self.name) end - assert(posix.link(self.path, self.confdir..'/'..self.fname, true)) + if self.enabled then printmsg('Policy already enabled: '..self.name) + else assert(posix.link(self.path, self.confdir..'/'..self.fname, true)) end end function Policy:disable() self:checkoptional() - if not self.enabled then raise('Policy already disabled: '..self.name) end - assert(os.remove(self.confdir..'/'..self.fname)) + if self.enabled then assert(os.remove(self.confdir..'/'..self.fname)) + else printmsg('Policy already disabled: '..self.name) end end |