Changes

Jump to navigation Jump to search
added the original link where the howto was for references
Line 1: Line 1:  
{{Level|Developer}}
 
{{Level|Developer}}
   −
{{warning box|msg= This documentation on how to build a panel in the server-manager is completely deprecated but it can bring to the developers some tricks to understand what is occurring in an old contrib. Please if you intend to build a panel you should use formagick instead of the perl cgi}}
+
{{warning box|msg= '''This documentation on how to build a panel in the server-manager is completely deprecated''' but it can bring to the developers some tricks to understand what is occurring in old contribs. Please if you intend to build a panel you should use formagick instead of the perl cgi}}
[http://www.sme-server.de/download/Howtos/e-smith_panel_howto.html original Author]
+
[http://dungog.net/wiki/Main_Page original Author] <br />
 +
 
 +
[http://www.sme-server.de/download/Howtos/e-smith_panel_howto.html original link]
 
===Introduction===
 
===Introduction===
 
Writing a panel for an e-smith server need not be difficult. By choosing an existing panel that is similar to what you need you can get a head start. You need only a small background in any sort of programming, coding html or similar.
 
Writing a panel for an e-smith server need not be difficult. By choosing an existing panel that is similar to what you need you can get a head start. You need only a small background in any sort of programming, coding html or similar.
Line 474: Line 476:  
             db_get
 
             db_get
 
             db_delete
 
             db_delete
 
+
 
             db_set_type
 
             db_set_type
 
             db_get_type
 
             db_get_type
 
+
 
             db_get_prop
 
             db_get_prop
 
             db_set_prop
 
             db_set_prop
 
             db_delete_prop
 
             db_delete_prop
 
+
 
             db_print
 
             db_print
 
             db_show
 
             db_show
 
+
 
             db_print_type
 
             db_print_type
 
             db_print_prop
 
             db_print_prop
 
* examples
 
* examples
   −
/home/e-smith/configuration
+
/home/e-smith/configuration
AccessType=dialup
+
AccessType=dialup
sshd=service|InitscriptOrder|05|status|enabled
+
sshd=service|InitscriptOrder|05|status|enabled
   −
/home/e-smith/accounts
+
/home/e-smith/accounts
jim=user|EmailForward|local|LastName|Morrison
+
jim=user|EmailForward|local|LastName|Morrison
cdrom=system
+
cdrom=system
cgi-bin=url
+
cgi-bin=url
jim.morrison=pseudonym|account|jim
+
jim.morrison=pseudonym|account|jim
   −
$hash ; the file containing the variables
+
$hash ; the file containing the variables
/home/e-smith/configuration
+
/home/e-smith/configuration
or /home/e-smith/accounts
+
or /home/e-smith/accounts
shown as /%conf or /%accounts in the panel perl code
+
shown as /%conf or /%accounts in the panel perl code
   −
key/value pairs
+
key/value pairs
$key ; AccessType, cdrom, cgi-bin, jim.morrison
+
$key ; AccessType, cdrom, cgi-bin, jim.morrison
$new_value ; dialup, system, url
+
$new_value ; dialup, system, url
   −
key/property|value sets
+
key/property|value sets
$key ; sshd, jim, jim.morrison
+
$key ; sshd, jim, jim.morrison
$type ;service, user, pseudonym
+
$type ;service, user, pseudonym
$prop ;InitscriptOrder, EmailForward, account, status
+
$prop ;InitscriptOrder, EmailForward, account, status
$new_value ;  05,  local,  Morrison,  jim,  enabled
+
$new_value ;  05,  local,  Morrison,  jim,  enabled
   −
$hashref ; see below for explanation
+
$hashref ; see below for explanation
    
* explanations
 
* explanations
Line 527: Line 529:  
  # It returns one on success and undef on failure.
 
  # It returns one on success and undef on failure.
 
  #--------------------------------------------------------------------------
 
  #--------------------------------------------------------------------------
 
+
 
  sub db_set (%$$;$)
 
  sub db_set (%$$;$)
 
   my ($hash, $key, $new_value, $hashref)
 
   my ($hash, $key, $new_value, $hashref)
Line 544: Line 546:  
  # suitable for assigning to a type and properties hash list)
 
  # suitable for assigning to a type and properties hash list)
 
  # or undef if the key does not exist.  
 
  # or undef if the key does not exist.  
 
+
 
  sub db_get (%;$)
 
  sub db_get (%;$)
 
   my ($hash, $key)
 
   my ($hash, $key)
Line 555: Line 557:  
  # Takes a reference to a hash and a scalar key and deletes the key. It
 
  # Takes a reference to a hash and a scalar key and deletes the key. It
 
  # returns one on success and undef if the key does not exist.  
 
  # returns one on success and undef if the key does not exist.  
 
+
 
  sub db_delete (%$;)
 
  sub db_delete (%$;)
 
   my ($hash, $key)
 
   my ($hash, $key)
Line 570: Line 572:  
  # Takes a reference to a hash, a scalar key and a scalar value and sets
 
  # Takes a reference to a hash, a scalar key and a scalar value and sets
 
  # the type for the key. It returns one on success and undef on failure.
 
  # the type for the key. It returns one on success and undef on failure.
 
+
 
  sub db_set_type (%$$;)
 
  sub db_set_type (%$$;)
 
   my ($hash, $key, $type)
 
   my ($hash, $key, $type)
Line 579: Line 581:  
  # Takes a reference to a hash and a scalar key and returns the type
 
  # Takes a reference to a hash and a scalar key and returns the type
 
  # associated with the key. It returns undef if the key does not exist.  
 
  # associated with the key. It returns undef if the key does not exist.  
 
+
 
  sub db_get_type (%$;)
 
  sub db_get_type (%$;)
 
   my ($hash, $key)
 
   my ($hash, $key)
Line 599: Line 601:  
  # scalar value and sets the property from the value. It returns with
 
  # scalar value and sets the property from the value. It returns with
 
  # the return status of db_set or undef if the key does not exist.
 
  # the return status of db_set or undef if the key does not exist.
 
+
 
  sub db_set_prop (%$$$;)
 
  sub db_set_prop (%$$$;)
 
  ((
 
  ((
Line 620: Line 622:  
  # hash of all properties for the key. It returns undef if the key or
 
  # hash of all properties for the key. It returns undef if the key or
 
  # the property does not exist.  
 
  # the property does not exist.  
 
+
 
  sub db_get_prop (%$;$)
 
  sub db_get_prop (%$;$)
 
   my ($hash, $key, $prop)
 
   my ($hash, $key, $prop)
Line 634: Line 636:  
  # deletes the property from the value. It returns with the return status
 
  # deletes the property from the value. It returns with the return status
 
  # of db_set or undef if the key or the property do not exist.
 
  # of db_set or undef if the key or the property do not exist.
 
+
 
  sub db_delete_prop (%$$;)
 
  sub db_delete_prop (%$$;)
 
   my ($hash, $key, $prop)
 
   my ($hash, $key, $prop)
Line 655: Line 657:  
  # the scalar key is provided, it prints key=value for that key. It
 
  # the scalar key is provided, it prints key=value for that key. It
 
  # returns one on success or undef if the key does not exist.
 
  # returns one on success or undef if the key does not exist.
 
+
 
  sub db_print (%;$)
 
  sub db_print (%;$)
 
   my ($hash, $key)
 
   my ($hash, $key)
Line 667: Line 669:  
  # that key. The value is expanded to show properties. It returns one
 
  # that key. The value is expanded to show properties. It returns one
 
  # on success or undef if the key does not exist.
 
  # on success or undef if the key does not exist.
 
+
 
  sub db_show (%;$)
 
  sub db_show (%;$)
 
   my ($hash, $key)
 
   my ($hash, $key)
Line 678: Line 680:  
  # the scalar key is provided, it prints key=type for that key. It
 
  # the scalar key is provided, it prints key=type for that key. It
 
  # returns one on success or undef if the key does not exist.
 
  # returns one on success or undef if the key does not exist.
 
+
 
  sub db_print_type (%;$)
 
  sub db_print_type (%;$)
 
   my ($hash, $key)
 
   my ($hash, $key)
Line 690: Line 692:  
  # provided, it prints prop=value for that key. It returns one on success
 
  # provided, it prints prop=value for that key. It returns one on success
 
  # or undef if the key or property does not exist.
 
  # or undef if the key or property does not exist.
 
+
 
  sub db_print_prop (%$;$)
 
  sub db_print_prop (%$;$)
 
   my ($hash, $key, $prop)
 
   my ($hash, $key, $prop)
Line 696: Line 698:  
===Basic Perl===
 
===Basic Perl===
 
A few samples that demonstrate correct coding practise. In areas of logic, Testing user input, and calling events and unix programs.
 
A few samples that demonstrate correct coding practise. In areas of logic, Testing user input, and calling events and unix programs.
====Logic===
+
====Logic====
"||" gives an answer if the first try didn't work.
+
* "||" gives an answer if the first try didn't work.
    
       my $FetchmailFreqOffice = db_get_prop(\%conf, "fetchmail", "FreqOffice")
 
       my $FetchmailFreqOffice = db_get_prop(\%conf, "fetchmail", "FreqOffice")
Line 709: Line 711:  
     'standard';
 
     'standard';
   −
"if (defined $something)" if defined then first else second
+
* "if (defined $something)" if defined then first else second
    
     my $SecondaryMailUseEnvelope;
 
     my $SecondaryMailUseEnvelope;
Line 722: Line 724:  
     }
 
     }
   −
"&&" if true twice continue
+
* "&&" if true twice continue
    
     if (defined $backup_status && $backup_status eq "enabled")
 
     if (defined $backup_status && $backup_status eq "enabled")
Line 783: Line 785:  
If you have a lot of tests you can define a set of expressions, describe them, and test for them
 
If you have a lot of tests you can define a set of expressions, describe them, and test for them
   −
#define expression to test
+
* define expression to test
 
my $REGEXPHostname = '([a-z0-9][a-z0-9-\.]*)';
 
my $REGEXPHostname = '([a-z0-9][a-z0-9-\.]*)';
 
my $REGEXPIPAddress = '(self|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})';
 
my $REGEXPIPAddress = '(self|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})';
Line 789: Line 791:       −
#advice to user
+
* advice to user
 
     esmith::cgi::genTextRow ($q, $q->p ( 'The IP address displayed
 
     esmith::cgi::genTextRow ($q, $q->p ( 'The IP address displayed
 
       is the IP address of the e-smith server. If this hostname
 
       is the IP address of the e-smith server. If this hostname
Line 796: Line 798:  
       address in the format "aaa.bbb.ccc.ddd"' )),
 
       address in the format "aaa.bbb.ccc.ddd"' )),
   −
#get input
+
* get input
 
     esmith::cgi::genNameValueRow ($q,
 
     esmith::cgi::genNameValueRow ($q,
 
                       "Hostname",
 
                       "Hostname",
 
                       "HostName",
 
                       "HostName",
 
                       ""),
 
                       ""),
#test input
+
* test input
 
     my $MACAddress = lc($q->param ('MACAddress'));
 
     my $MACAddress = lc($q->param ('MACAddress'));
   Line 844: Line 846:  
===References===
 
===References===
 
====Bugs====
 
====Bugs====
Syntax errors are common, a misplaced , or missed ) will result in a panel that will not run or compile.
+
Syntax errors are common, a misplaced , or missed ) will result in a panel that will not run or compile. Look in /var/log/httpd/admin_error_log for errors or admin_access_log will report success.
Look in /var/log/httpd/admin_error_log for errors
+
 
or admin_access_log will report success.
+
Check that httpd-admin is running as well as httpd, via a  
Check that httpd-admin is running as well as httpd, via a ps -A |grep httpd.
+
ps -A |grep httpd.
    
Check you have correct permissions, and locate/link it the e-smith way
 
Check you have correct permissions, and locate/link it the e-smith way
cd /etc/e-smith/web/functions/
+
cd /etc/e-smith/web/functions/
chmod 750 thing, then chmod u+s thing (?sn)
+
chmod 750 thing, then chmod u+s thing (?sn)
cd /etc/e-smith/web/panel/manager/cgi-bin
+
cd /etc/e-smith/web/panel/manager/cgi-bin
ln -s ../../../thing thing
+
ln -s ../../../thing thing
Links
+
 
www.e-smth.org duh
+
====Links====
www.perl.org
+
www.e-smth.org duh
Thanks
+
www.perl.org
 +
 
 +
====Thanks====
 
A big thank you to Gordon, Charlie and the e-smith team.
 
A big thank you to Gordon, Charlie and the e-smith team.
   −
Stephen Noble April 2001 ver 0.1-2
+
Stephen Noble April 2001 ver 0.1-2

Navigation menu