system — Plugin for managing a host’s system configuration

class EFTWKeepaliveThread(username, last_keepalive)

Kills a user’s EFTW session if the client hasn’t updated the keepalive within 30 seconds. Note: This is necessary to prevent shells from running eternally in the background.

keepalive(last_keepalive)
Updates the keepalive timeout
class System

A plugin for managing your system.

BackupAndRestore()
Render the backup and restore page where users can download/upload a tarball containing the contents of /etc.
Hostname()
Render a page where the user can change the system’s hostname.
Hosts()
Render a page where the user can edit /etc/hosts.
InitScripts()
Render a page where the user can stop, start, restart, and configure system init scripts (i.e. the scripts in /etc/init.d/ and /etc/rc.d).
Reboot()

Render a page where the user can reboot the system.

Note the capital R in ‘Reboot’. Not to be confused with ‘reboot’ which immediately reboots the system.

SystemLogs()
Render the main system log (syslog) and kernel log (dmesg) page. Default view is the syslog.
Timezone()
Render the timezone modification page.
UsersAndGroups()
Render the users and groups administration page
add_group(group, gid=None, users=None, **kwargs)
Add a group to /etc/group. Requires a group name, ‘group’ and optionally accepts a gid and list of users. ‘users’ can either be a Python list or a comma-separated string.
add_user(username, shell=None, password=None, uid=None, gid=None, gecos=None, groups=None, homedir=None, **kwargs)
Add a user
backup()
Returns a compressed tarball containing the contents of /etc that can be used by self.restore.
change_user_attribute(username, **attributes)
Changes a given user’s attribute in /etc/passwd and /etc/shadow (if present). Valid attributes are: username, password, uid, gid, gecos, homedir, shell, disable (password), and locked (password).
delete_group(groupname)
Permanentely deletes the given user
delete_user(username)
Permanentely deletes the given user and removes that user from any groups it resides in.
dmesg_tab()
Render the kernel log view tab.
eftw(chars=None, rows=None, cols=None, **kw)
Provides an Ajaxterm-like window...
eftw_terminal_size(rows, cols, **kw)
Sets the server-side terminal window size and also stores it in the client’s session. (Useful for when the browser window is resized)
get_groups_spreadsheet()
Exports the group permissions table as a spreadsheet
get_hosts_spreadsheet()
Exports /etc/hosts as a spreadsheet
get_initscript(script)
Returns the text of the given script as a string
get_initscripts_spreadsheet()
Exports the init scripts grid as a spreadsheet
get_raw_passwd()
Returns the raw passwd file
get_syslog_spreadsheet()
Exports the syslog grid as a spreadsheet
get_users_spreadsheet()
Exports the user permissions table as a spreadsheet
groups_json(rows=None, sidx=None, _search=None, searchField=None, searchOper=None, searchString=None, page=None, sord=None, nd=None)
Returns all groups from /etc/group in a json format that’s compatible with jqGrid.
hosts_json(rows=None, sidx=None, _search=None, searchField=None, searchOper=None, searchString=None, page=None, sord=None, nd=None)
Returns /etc/hosts in a json format that’s compatible with jqGrid.
initscript_service_control(oper, service=None)
Stop, Start, or Restart the given service depending on the value of ‘oper’: ‘start’ ‘stop’ ‘restart’
initscripts_json(rows=None, sidx=None, _search=None, searchField=None, searchOper=None, searchString=None, page=None, sord=None, nd=None)
Returns /etc/hosts in a json format that’s compatible with jqGrid. Note: Appends an empty list item to each script’s list as a placeholder for the Action column.
reboot()
Reboots the system
restore(backup)
Restores /etc using the given ‘backup_file’ which should be a tarball created using self.backup()
syslog_conf()
Render the syslog configuration tab.
syslog_json(rows=None, sidx=None, _search=None, searchField=None, searchOper=None, searchString=None, page=None, sord=None, nd=None)
Returns the syslog (via ‘logread’) in a json format that’s compatible with jqGrid.
syslog_options_meta(option=None, section=None, help=True, values=False, **data)
By default, return help text for the provided system option (for jTip). If ‘values’ is True, return a json-formatted list of possible values for the given option/section. If ‘section’ is provided, attempt to obtain valid values from the specified section of the validation file.
syslog_tab()
Render the syslog view/sort/search tab.
update_groups(oper=None, id=None, group=None, gid=None, users=None)
jqGrid function: Perform the specified operation on the specified user.
update_hostname(hostname)

Updates the system hostname with the given hostname.

That means writing the hostname to /proc/sys/kernel/hostname ...and if it exists, update /etc/hostname ...and if this is OpenWRT, update /etc/config/system too

update_hosts(oper=None, ip=None, hostnames=None, id=None)
Updates /etc/hosts with the given parameters.
update_initscript(script=None, oper=None, script_text=None, id=None, start=None, enabled=None)
Updates the given init.d script with the provided script_text or performs the given operation (oper)
update_raw_group(group)
Save the raw /etc/group file text as submitted
update_raw_passwd(passwd)
Save the raw passwd file text as submitted
update_raw_shadow(shadow)
Save the raw passwd file text as submitted
update_syslog_conf(log_ip, log_size)
Updates the system log configuration with the supplied options.
update_timezone(timezone)
Updates the system timezone and zonename with the given timezone
update_users(oper=None, id=None, shell=None, gecos=None, uid=None, gid=None, homedir=None, user=None)
jqGrid function: Perform the specified operation on the specified user.
users_json(rows=None, sidx=None, _search=None, searchField=None, searchOper=None, searchString=None, page=None, sord=None, nd=None)
Returns all users from /etc/passwd in a json format that’s compatible with jqGrid.
validate_option(config=None, section=None, **kwargs)
Returns a json-encoded error message if the given option:value pair does not validate
delayed_remove_file(filepath, delay=300)
Waits ‘delay’ seconds before removing the file at ‘filepath’. Default delay is 300 seconds (5 minutes)
disable_initscript(script)
Disables the given init script by removing its links from /etc/rc.d
gen_unique_gid(range_start=None, range_end=None)
Returns a unique GID (one not already used in /etc/group) starting at 1000 and ending at 100,000 by default. Optional: Return a GID in the provided range (range_start/range_end). ...raises an exception if there are no free IDs in the given range.
gen_unique_uid(range_start=None, range_end=None)
Returns a unique UID (one not already used in /etc/passwd) starting at 1000 and ending at 100,000 by default. Optional: Return a UID in the provided range (range_start/range_end). ...raises an exception if there are no free IDs in the given range.
html_escape(text)
Produce entities within text.
isrunning(pid)
Returns True if the process associated with pid is still alive
list_etc_hosts()
Returns /etc/hosts as a list of lists. Suitable for things like jqgrid and spreadsheet output
list_init_scripts()

Returns a list of lists of all init scripts in the following format (all strings): [

[
<init.d script name>, <rc.d link name(s)>, <enabled: true/false>, <valid/invalid>, <START value>

],

]

logread(date_format=None)

Parses the output of the ‘logread’ command and returns it as a list of lists in the following format:

[
[datetime_obj, hostname, facility, priority, process, pid, message],

]

If a date_format is given, log dates will be converted to a string before being added to the output like so: datetime_obj.strftime(date_format)

valid_shells()
Returns a list of all shells in /etc/shells
write_etc_hosts(text)
Overwrites /etc/hosts with ‘text’ ...to save duplicated code