Changes

From SME Server
Jump to navigationJump to search
4,936 bytes added ,  04:53, 5 February 2023
Line 71: Line 71:  
use esmith::Build::CreateLinks qw(:all);
 
use esmith::Build::CreateLinks qw(:all);
   −
my $pkg= "smeserver-foo";
+
my $pkg= "smeserver-mycontrib";
 
my $event = "${pkg}-update";
 
my $event = "${pkg}-update";
   Line 81: Line 81:     
event_templates($event, qw(
 
event_templates($event, qw(
 +
/etc/e-smith/db/configuration/migrate/80mycontrib
 
/etc/httpd/conf/httpd.conf
 
/etc/httpd/conf/httpd.conf
 
/etc/opt/remi/php80/php-fpm.d/www.conf
 
/etc/opt/remi/php80/php-fpm.d/www.conf
Line 89: Line 90:  
     php80-php-fpm restart
 
     php80-php-fpm restart
 
     httpd-e-smith restart
 
     httpd-e-smith restart
     foo restart
+
     mysql.init restart
 +
    mycontrib restart
 
));
 
));
   Line 100: Line 102:     
== Configuration DB ==
 
== Configuration DB ==
 +
In order to have a service to start using systemd, you need it to be defined in the e-smith configuration db, here is the bare minimum:<syntaxhighlight lang="bash">
 +
echo "service" > smeserver-mycontrib-1.0/root/etc/e-smith/db/configuration/defaults/mycontrib/type
 +
echo "enabled" > smeserver-mycontrib-1.0/root/etc/e-smith/db/configuration/defaults/mycontrib/status
 +
 +
</syntaxhighlight>You might also need to add a '''TCPPort''' or '''TCPPorts''' property if needed to open ports in firewall, and also an '''access''' property to make access private or public (default is localhost). You can also populate any dedicated property you would need for your own use.
    
== Mariadb myslq init ==
 
== Mariadb myslq init ==
 +
 +
=== default user, password and db for your app ===
 +
create the following file to generate the default password dbname and dbuser
 +
 +
smeserver-mycontrib-1.0/root/etc/e-smith/db/configuration/migrate/80mycontrib<syntaxhighlight lang="perl">
 +
{
 +
  use MIME::Base64 qw(encode_base64);
 +
 +
  my $rec = $DB->get('mycontrib') || $DB->new_record('mycontrib', {type => 'service'});
 +
 +
  my $pw = $rec->prop('DbPassword');
 +
  return "" if $pw;
 +
  $pw = MIME::Base64::encode(int( (1000000000000000) * rand() ));
 +
  chomp($pw);
 +
  $rec->set_prop('DbPassword', "$pw" );
 +
}
 +
 +
</syntaxhighlight>and the following <syntaxhighlight lang="bash">
 +
echo "mycontrib" > smeserver-mycontrib-1.0/root/etc/e-smith/db/configuration/defaults/mycontrib/DbName
 +
echo "mycontrib" > smeserver-mycontrib-1.0/root/etc/e-smith/db/configuration/defaults/mycontrib/DbUser
 +
 +
</syntaxhighlight>
 +
 +
 +
Then, create a file in smeserver-mycontrib-1.0/root/etc/e-smith/templates/etc/e-smith/sql/init/80mycontrib<syntaxhighlight lang="perl">
 +
{
 +
  my $db = $mycontrib{DbName} || 'mycontrib';
 +
  my $user = $mycontrib{DbUser} || 'mycontrib';
 +
  my $pass = $mycontrib{DbPassword} || 'changeme';
 +
  $OUT .= <<END
 +
#! /bin/sh
 +
  if [ -d /var/lib/mysql/$db ]; then
 +
    exit
 +
  fi
 +
  /usr/bin/mysql <<EOF
 +
  CREATE DATABASE $db DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
 +
  use $db;
 +
  #Insert application specific command to create database structure
 +
 +
  use mysql;
 +
  GRANT ALL PRIVILEGES ON $db.* TO $user\@localhost
 +
          IDENTIFIED BY '$pass';
 +
  flush privileges;
 +
EOF
 +
END
 +
}
 +
 +
</syntaxhighlight>
    
== Systemd ==
 
== Systemd ==
Line 109: Line 164:  
# a dropin file as this one
 
# a dropin file as this one
   −
/usr/lib/systemd/system/foo.service.d/50koozali.conf<syntaxhighlight lang="yaml">
+
smeserver-mycontrib-1.0/root/usr/lib/systemd/system/foo.service.d/50koozali.conf<syntaxhighlight lang="yaml">
 
[Service]
 
[Service]
#first we reset the ExecStartPre
+
#first we reset the ExecStartPre, if we do not want the initial lines to be executed
 
ExecStartPre=
 
ExecStartPre=
 
#our needs
 
#our needs
Line 203: Line 258:     
== Apache httpd ==
 
== Apache httpd ==
 +
you will need to create a template fragment for your contrib in order to get it displayed by the httpd server. There are three major situations:
 +
 +
=== php-fpm using a subdir ===
 +
<syntaxhighlight lang="perl">
 +
{
 +
  $allow = ($access eq 'public')?'all granted':"ip $localAccess $externalSSLAccess";
 +
 +
 +
}
 +
Alias /nextcloud /usr/share/nextcloud
 +
  <Directory "/usr/share/nextcloud">
 +
    Options +FollowSymLinks
 +
    AllowOverride All
 +
    <FilesMatch \.php$>
 +
        SetHandler "proxy:unix:/var/run/php-fpm/php81-mycontrib.sock|fcgi://localhost"
 +
    </FilesMatch>
 +
    Require {$allow}
 +
    SetEnv HOME /usr/share/nextcloud
 +
    SetEnv HTTP_HOME /usr/share/nextcloud
 +
    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
 +
  </Directory>
 +
  <Directory "/home/e-smith/files/nextcloud/data/">
 +
    # just in case if .htaccess gets disabled
 +
    Require all denied
 +
  </Directory>
 +
 +
</syntaxhighlight>
 +
 +
=== php-fpm using a dedicated virtualhost ===
 +
You can simply use the virtualhost template  subfolder WebAppVirtualHost/ or create your own. If you want to create your own check the content of  /etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost and adapt it to your needs with a new path
 +
 +
Then the admin after installing the contrib can set the dedicated virtualhost using the command <syntaxhighlight lang="bash">
 +
db domains set mycontrib.mydomain.com domain Content Primary  Description mycontrib DocumentRoot /usr/share/mycontrib Nameservers internet RequireSSL enabled TemplatePath WebAppVirtualHost letsencryptSSLcert enabled
 +
</syntaxhighlight>
 +
 +
=== proxypass to a port ===
 +
You can simply use the proxypass directive see [[SME Server:Documentation:ProxyPass]], either using a domain or an URI / location.
 +
 +
You can also create your own template fragment like 99madsonic<syntaxhighlight lang="perl">
 +
{
 +
 +
  $OUT .= "  # static html, js, images, etc. served from coolwsd\n";
 +
    $OUT .= "  # browser is the client part of LibreOffice Online\n";
 +
    $OUT .= "  ProxyPass          /browser http://127.0.0.1:9980/browser retry=0\n";
 +
    $OUT .= "  ProxyPassReverse    /browser http://127.0.0.1:9980/browser\n";
 +
 +
    $OUT .= "  # WOPI discovery URL\n";
 +
    $OUT .= "  ProxyPass          /hosting/discovery http://127.0.0.1:9980/hosting/discovery retry=0\n";
 +
    $OUT .= "  ProxyPassReverse    /hosting/discovery http://127.0.0.1:9980/hosting/discovery\n";
 +
 +
 +
 +
}
 +
 +
 +
</syntaxhighlight>
 +
 +
== Assemble and build ==
 +
Final step is to assemble your archive content, and build a rpm. This is quite similar to what you can see in  [[Package Modification]] or [[Package Import]]
 
[[Category:Developer]]
 
[[Category:Developer]]
Super Admin, Wiki & Docs Team, Bureaucrats, Interface administrators, Administrators
3,254

edits

Navigation menu