From bf53dcc1b2930a8dd3b81525599d477237e3e4a4 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 10 Aug 2015 23:05:46 +0200 Subject: lcdproc - code style fixes - Fix copyright header - Remove useless/unused functions - Use is_process_running() / stop_service() / restart_service() - Remove useless config_lock() / config_unlock() - Indentation and code style fixes --- config/lcdproc/lcdproc.inc | 714 ++++++++++++++++++++++----------------------- 1 file changed, 345 insertions(+), 369 deletions(-) diff --git a/config/lcdproc/lcdproc.inc b/config/lcdproc/lcdproc.inc index 2251618c..9aecfa3b 100644 --- a/config/lcdproc/lcdproc.inc +++ b/config/lcdproc/lcdproc.inc @@ -1,347 +1,323 @@ - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. + lcdproc.inc + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2007-2009 Seth Mos + Copyright (C) 2009 Scott Ullrich + Copyright (C) 2011 Michele Di Maria + Copyright (C) 2015 ESF, LLC + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. */ - - require_once("config.inc"); - require_once("functions.inc"); - - /* LCDproc */ - define('LCDPROC_RCFILE', '/usr/local/etc/rc.d/lcdproc.sh'); - define('LCDPROC_CLIENT', '/tmp/lcdclient.sh'); - $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); - if ($pfs_version == "2.1" || $pfs_version == "2.2") { - define('LCDPROC_CONFIG', '/usr/pbi/lcdproc-' . php_uname('m') . '/local/etc/LCDd.conf'); - } else { - define('LCDPROC_CONFIG','/usr/local/etc/LCDd.conf'); +require_once("config.inc"); +require_once("functions.inc"); + +/* LCDproc */ +define('LCDPROC_RCFILE', '/usr/local/etc/rc.d/lcdproc.sh'); +define('LCDPROC_CLIENT', '/tmp/lcdclient.sh'); +$pfs_version = substr(trim(file_get_contents("/etc/version")), 0, 3); +if ($pfs_version == "2.1" || $pfs_version == "2.2") { + define('LCDPROC_CONFIG', '/usr/pbi/lcdproc-' . php_uname('m') . '/local/etc/LCDd.conf'); +} else { + define('LCDPROC_CONFIG','/usr/local/etc/LCDd.conf'); +} +define('LCDPROC_HOST','127.0.0.1'); +define('LCDPROC_PORT','13666'); + +function lcdproc_notice ($msg) { + syslog(LOG_NOTICE, "lcdproc: {$msg}"); +} + +function lcdproc_warn ($msg) { + syslog(LOG_WARNING, "lcdproc: {$msg}"); +} + +function lcdproc_write_config($file, $text) { + $handle = fopen($file, 'w'); + if (!$handle) { + lcdproc_warn("Could not open {$file} for writing."); + exit; } - define('LCDPROC_HOST','127.0.0.1'); - define('LCDPROC_PORT','13666'); - - function lcdproc_notice ($msg) { syslog(LOG_NOTICE, "lcdproc: {$msg}"); } - function lcdproc_warn ($msg) { syslog(LOG_WARNING, "lcdproc: {$msg}"); } - - function lcdproc_action ($action) { - if (file_exists(LCDPROC_RCFILE)) - mwexec(LCDPROC_RCFILE.' '.$action); + fwrite($handle, $text); + fclose($handle); +} + +function lcdproc_write_script($file, $text) { + $handle = fopen($file, 'wx'); + if (!$handle) { + lcdproc_warn("Could not open {$file} for writing."); + exit; } - - function lcdproc_running () { - if((int)exec('pgrep LCDd | wc -l') > 0) - return true; - return false; - } - - function lcdproc_write_config($file, $text) { - $handle = fopen($file, 'w'); - if(!$handle) { - lcdproc_warn("Could not open {$file} for writing."); - exit; + fwrite($handle, $text); + fclose($handle); + chmod($file, 0755); +} + +function validate_form_lcdproc($post, &$input_errors) { + if ($post['comport']) { + switch ($post['comport']) { + case "none": + continue; + break; + case "com2": + continue; + break; + case "ucom1": + continue; + break; + case "ucom2": + continue; + break; + case "lpt1": + continue; + break; + case "ugen0.2": + continue; + break; + case "ugen1.2": + continue; + break; + case "ugen2.2": + continue; + break; + default: + $input_errors[] = "The chosen com port is not valid"; + break; } - fwrite($handle, $text); - fclose($handle); } - - function lcdproc_write_script($file, $text) { - $handle = fopen($file, 'wx'); - if(!$handle) { - lcdproc_warn("Could not open {$file} for writing."); - exit; + if ($post['size']) { + switch ($post['size']) { + case "12x1": + continue; + break; + case "12x2": + continue; + break; + case "12x4": + continue; + break; + case "16x1": + continue; + break; + case "16x2": + continue; + break; + case "16x4": + continue; + break; + case "20x1": + continue; + break; + case "20x2": + continue; + break; + case "20x4": + continue; + break; + default: + $input_errors[] = "The chosen display size is not valid"; + break; } - fwrite($handle, $text); - fclose($handle); - chmod($file, 0755); - } - - function before_form_lcdproc(&$pkg) { - global $config; - - config_lock(); - - config_unlock(); - } - - function before_form_lcdproc_screens(&$pkg) { - global $config; - - config_lock(); - - config_unlock(); } - - function validate_form_lcdproc($post, &$input_errors) { - if($post['comport']) { - switch($post['comport']) { - case "none": - continue; - break; - case "com2": - continue; - break; - case "ucom1": - continue; - break; - case "ucom2": - continue; - break; - case "lpt1": - continue; - break; - case "ugen0.2": - continue; - break; - case "ugen1.2": - continue; - break; - case "ugen2.2": - continue; - break; - default: - $input_errors[] = "The chosen com port is not valid"; - break; - } +} + +function sync_package_lcdproc_screens() { + sync_package_lcdproc(); +} + +function sync_package_lcdproc() { + global $g; + global $config; + global $input_errors; + + $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0]; + $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; + + /* Since config is written before this file invoked, we don't need to read post data */ + if ($lcdproc_config['enable'] && ($lcdproc_config['comport'] != "none")) { + switch ($lcdproc_config['comport']) { + case "com2": + $realport = "/dev/cua1"; + break; + case "ucom1": + $realport = "/dev/cuaU0"; + break; + case "ucom2": + $realport = "/dev/cuaU1"; + break; + case "lpt1": + $realport = "/dev/lpt0"; + break; + case "ugen0.2": + $realport = "/dev/ugen0.2"; + break; + case "ugen1.2": + $realport = "/dev/ugen1.2"; + break; + case "ugen2.2": + $realport = "/dev/ugen2.2"; + break; + default: + lcdproc_warn("The selected com port is not valid!"); + return; } - if($post['size']) { - switch($post['size']) { - case "12x1": - continue; - break; - case "12x2": - continue; - break; - case "12x4": - continue; - break; - case "16x1": - continue; - break; - case "16x2": - continue; - break; - case "16x4": - continue; - break; - case "20x1": - continue; - break; - case "20x2": - continue; - break; - case "20x4": - continue; - break; - default: - $input_errors[] = "The chosen display size is not valid"; - break; - } - } - } - function validate_form_lcdproc_screens($post, &$input_errors) { - // No validation required ?! - } - - function sync_package_lcdproc_screens() { - sync_package_lcdproc(); - } - function sync_package_lcdproc() { - global $g; - global $config; - global $input_errors; - - config_lock(); - - $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0]; - $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; - - /* since config is written before this file invoked we don't need to read post data */ - if($lcdproc_config['enable'] && ($lcdproc_config['comport'] != "none")) { - switch($lcdproc_config['comport']) { - case "com2": - $realport = "/dev/cua1"; - break; - case "ucom1": - $realport = "/dev/cuaU0"; - break; - case "ucom2": - $realport = "/dev/cuaU1"; - break; - case "lpt1": - $realport = "/dev/lpt0"; - break; - case "ugen0.2": - $realport = "/dev/ugen0.2"; - break; - case "ugen1.2": - $realport = "/dev/ugen1.2"; - break; - case "ugen2.2": - $realport = "/dev/ugen2.2"; - break; - default: - lcdproc_warn("The selected com port is not valid!"); - return; - } - - $config_text = "[server]\n"; - $config_text .= "Driver={$lcdproc_config[driver]}\n"; - $config_text .= "Bind=127.0.0.1\n"; - $config_text .= "Port=13666\n"; - $config_text .= "ReportLevel=3\n"; - $config_text .= "ReportToSyslog=yes\n"; - $config_text .= "WaitTime=5\n"; - $config_text .= "User=nobody\n"; - $config_text .= "ServerScreen=no\n"; - $config_text .= "Foreground=no\n"; - $config_text .= "DriverPath=/usr/local/lib/lcdproc/\n"; - $config_text .= "GoodBye=\"Thanks for using\"\n"; - $config_text .= "GoodBye=\" {$g['product_name']} \"\n"; - /* FIXME: Specific to the pyramid project */ - $config_text .= "ToggleRotateKey=Enter\n"; - $config_text .= "PrevScreenKey=Left\n"; - $config_text .= "NextScreenKey=Right\n"; - $config_text .= "ScrollUpKey=Up\n"; - $config_text .= "ScrollDownKey=Down\n"; - /* FIXME: pyramid test menu */ - $config_text .= "[menu]\n"; - $config_text .= "MenuKey=Escape\n"; - $config_text .= "EnterKey=Enter\n"; - $config_text .= "UpKey=Up\n"; - $config_text .= "DownKey=Down\n"; - /* lcdproc default driver definitions */ - switch($lcdproc_config[driver]) { - case "SureElec": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Edition=2\n"; - $config_text .= "Contrast=200\n"; - $config_text .= "Brightness=480\n"; - $config_text .= "Speed=19200\n"; - break; - case "nexcom": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - break; - case "bayrad": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Speed=9600\n"; - break; - case "picolcd": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "driverpath=/usr/local/lib/lcdproc/\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "KeyTimeout=500\n"; - $config_text .= "Brightness=1000\n"; - $config_text .= "Blacklight_Timer=60\n"; - $config_text .= "Contrast=1000\n"; - $config_text .= "Keylights=on\n"; - $config_text .= "Key0Light=on\n"; - $config_text .= "Key1Light=off\n"; - $config_text .= "Key2Light=off\n"; - $config_text .= "Key3Light=off\n"; - $config_text .= "Key4Light=off\n"; - $config_text .= "Key5Light=off\n"; - break; - case "CFontz": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Contrast=350\n"; - $config_text .= "Brightness=1000\n"; - $config_text .= "OffBrightness=50\n"; - $config_text .= "Speed=9600\n"; - $config_text .= "NewFirmware=no\n"; - $config_text .= "Reboot=no\n"; - break; - case "CFontz633": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Contrast=350\n"; - $config_text .= "Brightness=1000\n"; - $config_text .= "OffBrightness=50\n"; - $config_text .= "Speed=19200\n"; - $config_text .= "NewFirmware=yes\n"; - $config_text .= "Reboot=yes\n"; - break; - case "CFontzPacket": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Model=635\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Contrast=350\n"; - $config_text .= "Brightness=1000\n"; - $config_text .= "OffBrightness=50\n"; - $config_text .= "Speed=115200\n"; - $config_text .= "NewFirmware=yes\n"; - $config_text .= "Reboot=yes\n"; - break; - case "curses": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Foreground=blue\n"; - $config_text .= "Background=cyan\n"; - $config_text .= "Backlight=red\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "TopLeftX=7\n"; - $config_text .= "TopLeftY=7\n"; - $config_text .= "UseACS=no\n"; - break; - case "CwLynx": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Model=12232\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - $config_text .= "Speed=19200\n"; - $config_text .= "Reboot=no\n"; - break; - case "pyramid": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - break; - case "ea65": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "Device={$realport}\n"; - $config_text .= "OffBrightness=0\n"; - $config_text .= "Brightness=500\n"; - break; - default: - lcdproc_warn("The chosen lcdproc driver is not a valid choice"); - unset($lcdproc_config[driver]); - } + $config_text = "[server]\n"; + $config_text .= "Driver={$lcdproc_config[driver]}\n"; + $config_text .= "Bind=127.0.0.1\n"; + $config_text .= "Port=13666\n"; + $config_text .= "ReportLevel=3\n"; + $config_text .= "ReportToSyslog=yes\n"; + $config_text .= "WaitTime=5\n"; + $config_text .= "User=nobody\n"; + $config_text .= "ServerScreen=no\n"; + $config_text .= "Foreground=no\n"; + $config_text .= "DriverPath=/usr/local/lib/lcdproc/\n"; + $config_text .= "GoodBye=\"Thanks for using\"\n"; + $config_text .= "GoodBye=\" {$g['product_name']} \"\n"; + /* FIXME: Specific to the pyramid project */ + $config_text .= "ToggleRotateKey=Enter\n"; + $config_text .= "PrevScreenKey=Left\n"; + $config_text .= "NextScreenKey=Right\n"; + $config_text .= "ScrollUpKey=Up\n"; + $config_text .= "ScrollDownKey=Down\n"; + /* FIXME: pyramid test menu */ + $config_text .= "[menu]\n"; + $config_text .= "MenuKey=Escape\n"; + $config_text .= "EnterKey=Enter\n"; + $config_text .= "UpKey=Up\n"; + $config_text .= "DownKey=Down\n"; + + /* lcdproc default driver definitions */ + switch ($lcdproc_config[driver]) { + case "SureElec": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Edition=2\n"; + $config_text .= "Contrast=200\n"; + $config_text .= "Brightness=480\n"; + $config_text .= "Speed=19200\n"; + break; + case "nexcom": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "driverpath =/usr/local/lib/lcdproc/\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + break; + case "bayrad": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Speed=9600\n"; + break; + case "picolcd": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "driverpath=/usr/local/lib/lcdproc/\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "KeyTimeout=500\n"; + $config_text .= "Brightness=1000\n"; + $config_text .= "Blacklight_Timer=60\n"; + $config_text .= "Contrast=1000\n"; + $config_text .= "Keylights=on\n"; + $config_text .= "Key0Light=on\n"; + $config_text .= "Key1Light=off\n"; + $config_text .= "Key2Light=off\n"; + $config_text .= "Key3Light=off\n"; + $config_text .= "Key4Light=off\n"; + $config_text .= "Key5Light=off\n"; + break; + case "CFontz": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Contrast=350\n"; + $config_text .= "Brightness=1000\n"; + $config_text .= "OffBrightness=50\n"; + $config_text .= "Speed=9600\n"; + $config_text .= "NewFirmware=no\n"; + $config_text .= "Reboot=no\n"; + break; + case "CFontz633": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Contrast=350\n"; + $config_text .= "Brightness=1000\n"; + $config_text .= "OffBrightness=50\n"; + $config_text .= "Speed=19200\n"; + $config_text .= "NewFirmware=yes\n"; + $config_text .= "Reboot=yes\n"; + break; + case "CFontzPacket": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Model=635\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Contrast=350\n"; + $config_text .= "Brightness=1000\n"; + $config_text .= "OffBrightness=50\n"; + $config_text .= "Speed=115200\n"; + $config_text .= "NewFirmware=yes\n"; + $config_text .= "Reboot=yes\n"; + break; + case "curses": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Foreground=blue\n"; + $config_text .= "Background=cyan\n"; + $config_text .= "Backlight=red\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "TopLeftX=7\n"; + $config_text .= "TopLeftY=7\n"; + $config_text .= "UseACS=no\n"; + break; + case "CwLynx": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Model=12232\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + $config_text .= "Speed=19200\n"; + $config_text .= "Reboot=no\n"; + break; + case "pyramid": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "Size={$lcdproc_config['size']}\n"; + break; + case "ea65": + $config_text .= "[{$lcdproc_config['driver']}]\n"; + $config_text .= "Device={$realport}\n"; + $config_text .= "OffBrightness=0\n"; + $config_text .= "Brightness=500\n"; + break; + default: + lcdproc_warn("The chosen lcdproc driver is not a valid choice"); + unset($lcdproc_config[driver]); + } - /* generate rc file start and stop */ - $client_script = << 'lcdproc.sh', - 'start' => $start, - 'stop' => $stop - )); - conf_mount_ro(); - /* or restart lcdproc if settings were changed */ - if(lcdproc_running($_POST['comport'])) { - lcdproc_notice("Restarting service lcdproc"); - lcdproc_action('restart'); - } + $start = $stop ."\n"; + $start .= "\t/usr/local/sbin/LCDd -c ". LCDPROC_CONFIG ."\n"; + $start .= "\t". LCDPROC_CLIENT ." &\n"; + + /* Write out the configuration */ + conf_mount_rw(); + lcdproc_write_script(LCDPROC_CLIENT, $client_script); + lcdproc_write_config(LCDPROC_CONFIG, $config_text); + write_rcfile(array( + 'file' => 'lcdproc.sh', + 'start' => $start, + 'stop' => $stop + )); + conf_mount_ro(); + + /* Or restart lcdproc if settings were changed */ + if (is_process_running("LCDd") && ($_POST['comport'] != "")) { + lcdproc_notice("Restarting service lcdproc"); + restart_service("lcdproc"); } + } - if((! $lcdproc_config['driver']) || ($lcdproc_config['comport'] == "none")) { - /* no parameters user does not want lcdproc running */ - /* lets stop the service and remove the rc file */ + if ((! $lcdproc_config['driver']) || ($lcdproc_config['comport'] == "none")) { + /* No parameters - user does not want lcdproc running */ + /* Let's stop the service and remove the rc file */ - if(file_exists(LCDPROC_RCFILE)) { - if(!$lcdproc_config['enable']) { - lcdproc_notice('Stopping service: lcdproc disabled'); - } else { - lcdproc_notice('Stopping service: no com port selected'); - } - lcdproc_action('stop'); - conf_mount_rw(); - unlink(LCDPROC_RCFILE); - unlink(LCDPROC_CLIENT); - unlink(LCDPROC_CONFIG); - conf_mount_ro(); + if (file_exists(LCDPROC_RCFILE)) { + if (!$lcdproc_config['enable']) { + lcdproc_notice('Stopping service: lcdproc disabled'); + } else { + lcdproc_notice('Stopping service: no com port selected'); } + stop_service("lcdproc"); + conf_mount_rw(); + unlink(LCDPROC_RCFILE); + unlink(LCDPROC_CLIENT); + unlink(LCDPROC_CONFIG); + conf_mount_ro(); } - config_unlock(); } +} ?> -- cgit v1.2.3