From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: network@lists.ipfire.org Subject: Re: [PATCH] zone: response with an error if a zone is already up or down Date: Tue, 25 Jul 2017 23:32:08 +0100 Message-ID: <1501021928.20312.39.camel@ipfire.org> In-Reply-To: <1500988437-3732-1-git-send-email-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6845847898653138480==" List-Id: --===============6845847898653138480== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi, this patch looks logically fine, but I sometimes use the "up" function to rel= oad a zone which is no longer possible. And secondly, I am not sure if "zone_is_active" will return true when systemd has started the script. In that case, the "up" action would be called and ass= ume that everything is up already and therefore never bring up the zone. -Michael On Tue, 2017-07-25 at 15:13 +0200, Jonatan Schlag wrote: > Fixes: #11368 >=20 > Signed-off-by: Jonatan Schlag > --- > =C2=A0src/functions/functions.zone | 13 +++++++++++++ > =C2=A01 file changed, 13 insertions(+) >=20 > diff --git a/src/functions/functions.zone b/src/functions/functions.zone > index 91ce629..eccca3a 100644 > --- a/src/functions/functions.zone > +++ b/src/functions/functions.zone > @@ -369,6 +369,12 @@ zone_up() { > =C2=A0 return ${EXIT_ERROR} > =C2=A0 fi > =C2=A0 > + # Check if the zone is already up > + if zone_is_active ${zone}; then > + log ERROR "Zone ${zone} is already up" > + return ${EXIT_ERROR} > + fi > + > =C2=A0 # Check if a zone has got the remove tag. > =C2=A0 if zone_has_destroy_tag ${zone}; then > =C2=A0 error "Cannot bring up any zone which is to be removed." > @@ -405,6 +411,13 @@ zone_down() { > =C2=A0 return ${EXIT_ERROR} > =C2=A0 fi > =C2=A0 > + # Check if the zone is already down > + if ! zone_is_active ${zone}; then > + log ERROR "Zone ${zone} is already down" > + return ${EXIT_ERROR} > + fi > + > + > =C2=A0 local hook=3D"$(zone_get_hook "${zone}")" > =C2=A0 if [ -z "${hook}" ]; then > =C2=A0 error "Config file did not provide any hook." --===============6845847898653138480== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KVmVyc2lvbjogR251UEcgdjIKCmlRSWNCQUFC Q2dBR0JRSlpkOGJvQUFvSkVJQjU4UDl2a0FrSFlWMFAvMWhHRlJjZnlMMVpXNTJoYUFQTGF1MjMK cFlGYjVaSW1HWU80bXgzZXAwQ1NOaEJBSnJrR1RXRTFzd1VDZEh3WnJ0NnNRVjNJajQxOFc0QzlM SG15Ny9BNQpRT2pFODVXMG5Ed1FtUi92UWRiM09yZ3hKd3h6L1dLMzYybDFndzB4eGk5alpTTVFa bHhMOHBpRUZIU1hRdDN4CjNESVpuMTF0VVdoS2kwcWh6Z29kbVkweEEzWDdKMDNBV0FJQUQ5OVFI K0crUUUzQUNyQkdxYnhrWEFvTUN5ZEkKLy9VSk9sekozL0VaWko2R1NnbXlSY3FndXJZaUdKNlcz U2VRUlNPWEZ2dmpVelM4aW11TXZwdTN3bnYrL3N5VgpDcUNqNGxTZ09xNEdva3FjMHMvMVEvSE5Q eWhIWDEzNDc2OHFLSVIydnRJam5aYlBQbVhTZytCTmlvT2Q1RVhhClc2OFk5S0Yyem56THVCU01Z Vm9zNFM0SkxFWE5PSWNzd0RiZEpQRDNKZklsWHNRY2hjQUJueDEySFB1UkFVTksKSlFiQWJDZXRp THV0TnFhQUVFZFZ1UitCcVhJSW9BN2NkbEhCT3NiRG16Y3hrbGtqbFRkWDBERnBlT2V0czhabQo5 NENOKzRVeTdIc2ZyaHRsSDkxcUhtRGE0d1JDUGJ2eXh3MGJZTHh4eHArd05Ta3N2K3dPcDcxeWRy cGdvL2luCnV5aHhrYnBDTDRLenc4WnhnYzd0WUszRjg0SThsWFVlYlhrTDB1TjRPaU5KVmJsS1ha djlPbDJDNU1QTXEwaVYKSUpLeWNZejM2dkx3MVplNFhzWUswN29JM1YwZER2MWN2SWRpejZsdzBX dGsvU25qWXhSMG5UdkhyWEJkdFBkbQo4QlZCcytZaE42cFFobTQ4VTZEeAo9TW5xNgotLS0tLUVO RCBQR1AgU0lHTkFUVVJFLS0tLS0K --===============6845847898653138480==--