init of a filesystem checker plugin - not finished, yet
This commit is contained in:
parent
b0d2a2deae
commit
4c9b4e5a5b
31
plugins/volume_check_fs/language.hdf
Normal file
31
plugins/volume_check_fs/language.hdf
Normal file
|
@ -0,0 +1,31 @@
|
|||
Name = Plugin template
|
||||
Link = Template
|
||||
|
||||
Title = This is a plugin template
|
||||
|
||||
Text.Example = Think before you code.
|
||||
Text.SecondExample = And while probably won't hurt!
|
||||
|
||||
Help.Example = This template should help you with starting to write your own plugins. Please take a look in plugin-interfaces.txt for further assistance.
|
||||
|
||||
SuccessMessage {
|
||||
TemplateLaunched {
|
||||
Title = You see ...
|
||||
Text = an empty example for a plugin.
|
||||
}
|
||||
}
|
||||
|
||||
WarningMessage {
|
||||
SomeError {
|
||||
Title = Invalid value
|
||||
Text = This message will never appear.
|
||||
}
|
||||
}
|
||||
|
||||
EnvironmentWarning {
|
||||
MissingFoo {
|
||||
Title = Plugin template warning example
|
||||
Text = Use this to print some important warnings.
|
||||
}
|
||||
}
|
||||
|
97
plugins/volume_check_fs/volume_check_fs.py
Normal file
97
plugins/volume_check_fs/volume_check_fs.py
Normal file
|
@ -0,0 +1,97 @@
|
|||
#
|
||||
# Copyright 2006-2007 sense.lab e.V.
|
||||
#
|
||||
# This file is part of the CryptoBox.
|
||||
#
|
||||
# The CryptoBox 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.
|
||||
#
|
||||
# The CryptoBox 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 the CryptoBox; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
"""This is a plugin for automatic filesystem checks during mount
|
||||
|
||||
TODO: the plugin is not implemented, yet!
|
||||
|
||||
requires:
|
||||
- e2fsck (debian: e2fsprogs package)
|
||||
"""
|
||||
|
||||
__revision__ = ""
|
||||
|
||||
import cryptobox.plugins.base
|
||||
import os
|
||||
|
||||
DEFAULT_E2FSCK_BIN = "/sbin/e2fsck"
|
||||
|
||||
|
||||
class volume_check_fs(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||
"""a template for CryptoBox plugins
|
||||
"""
|
||||
|
||||
plugin_capabilities = [ "system" ]
|
||||
#plugin_visibility = [ "preferences" ]
|
||||
# TODO: enable, when the plugin is working
|
||||
plugin_visibility = [ ]
|
||||
request_auth = False
|
||||
rank = 99
|
||||
|
||||
def do_action(self):
|
||||
"""The action handler.
|
||||
"""
|
||||
# TODO: not implemented, yet
|
||||
return "form_plugin"
|
||||
|
||||
|
||||
def get_status(self):
|
||||
"""Retrieve the status of the feature.
|
||||
"""
|
||||
if self.__check_e2fsck_availability():
|
||||
return "installed"
|
||||
else:
|
||||
return "missing"
|
||||
|
||||
|
||||
def get_warnings(self):
|
||||
warnings = []
|
||||
if not self.__check_e2fsck_availability():
|
||||
warnings.append((32, "Plugins.%s.MissingProgramE2fsck" \
|
||||
% self.get_name()))
|
||||
return warnings
|
||||
|
||||
|
||||
def __check_e2fsck_availability(self):
|
||||
"""Test if the program e2fsck is installed
|
||||
"""
|
||||
if os.access(self.__get_e2fsck_location(), os.X_OK):
|
||||
return True
|
||||
else:
|
||||
self.cbox.log.warn("The recommended program 'e2fsck' is not " \
|
||||
+ "available - please install it!")
|
||||
return False
|
||||
|
||||
|
||||
def __get_e2fsck_location(self):
|
||||
"""get the location of the e2fsck binary
|
||||
|
||||
this setting may be changed in cryptobox.conf
|
||||
"""
|
||||
if "e2fsck_bin" in self.defaults:
|
||||
return self.defaults["e2fsck_bin"]
|
||||
else:
|
||||
return DEFAULT_E2FSCK_BIN
|
||||
|
||||
|
||||
def __prepare_form_data(self):
|
||||
"""Set some hdf values.
|
||||
"""
|
||||
|
Loading…
Reference in a new issue