#!/opt/opensvc/bin/python
#
# Copyright (c) 2009 Christophe Varoqui <christophe.varoqui@free.fr>'
# Copyright (c) 2009 Cyril Galibern <cyril.galibern@free.fr>'
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
import sys
import os

#
# add project lib to path
#
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'lib'))

from freezer import Freezer
from rcUtilities import check_privs

check_privs()

if len(sys.argv) == 1:
	f = Freezer()
elif len(sys.argv) == 2:
	f = Freezer(sys.argv[1])
else:
	print __file__ + " [service]"
	sys.exit(1)

cmd = os.path.basename(__file__)
if cmd == 'svcfreeze':
	sys.exit(f.freeze())
elif cmd == 'svcthaw':
	sys.exit(f.thaw())
elif cmd == 'svcfrozen':
	sys.exit(int(f.frozen()))
