Koozali.org: home of the SME Server
Contribs.org Forums => Development => Topic started by: MScapin on June 19, 2015, 02:48:18 PM
-
Hi !
This topic is the following part for the RPM creation for Syncthing :
http://forums.contribs.org/index.php/topic,51700.0.html
So, I read some documentations about templates and SMEServer personalization but I don't really understand the thing...
Docs :
- http://bugs.contribs.org/show_bug.cgi?id=8831
- http://distro.ibiblio.org/smeserver/contribs/gordonr/devguide/html/c1115.htm
- http://wiki.contribs.org/Template_Tutorial/fr
The aim is to make syncthing's config.xml install in /etc/syncthing/
So if I understand well, I have to create templates to personalize it ?
Or/And modify syncthing script (the one bellow) to set where the config.xml must be searched ?
#!/bin/sh
### BEGIN INIT INFO
# Provides: Syncthing
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Syncthing to sync folders
### END INIT INFO
SCRIPT=/home/syncthing/bin/syncthing
RUNAS=syncthing
NAME=syncthing
PIDFILE=/var/run/$NAME.pid
LOGFILE=/home/syncthing/log/$NAME.log
start() {
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
echo 'Service already running' >&2
return 1
fi
echo 'Starting serviceā¦' >&2
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
su -c "$CMD" $RUNAS > "$PIDFILE"
echo 'Service started' >&2
}
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running' >&2
return 1
fi
echo 'Stopping serviceā¦' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
}
uninstall() {
echo -n "Are you really sure you want to uninstall this service? That cannot be undone. [yes|No] "
local SURE
read SURE
if [ "$SURE" = "yes" ]; then
stop
rm -f "$PIDFILE"
echo "Notice: log file is not be removed: '$LOGFILE'" >&2
update-rc.d -f <NAME> remove
rm -fv "$0"
fi
}
status() {
printf "%-50s" "Checking $NAME..."
if [ -f $PIDFILE ]; then
PID=$(cat $PIDFILE)
if [ -z "$(ps axf | grep ${PID} | grep -v grep)" ]; then
printf "%s\n" "The process appears to be dead but pidfile still exists"
else
echo "Running, the PID is $PID"
fi
else
printf "%s\n" "Service not running"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
uninstall)
uninstall
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|status|restart|uninstall}"
esac
I'm not used to SMEServer, and Linux distributions generally, so I never handled those things :s
If you have some advises that can help me creating templates and modifying the script if needed, I'd be rather happy ! :D
Thanks a lot.
Best Regards,
MScapin.
-
You should have a look directly to the code of a contrib to understand how it works (think about also to the createlinks). You can also take a look into the the sme and look to /etc/e-smith/templates.
The principle is really simple
/etc/e-smith/templates/root/plop/10base
When you expand it
Expand-template /root/plop
You will find a file with the content you set in 10base
-
Steph, I'm actually trying to create the createlinks file and I saw yours for Roundcube (https://github.com/stephdl/smeserver-roundcube/blob/master/createlinks).
Could you explain what is done in this createlinks file ?
What should I put in mine ?
Thanks alot ! :)
-
It's a copy paste of my locked subjet (but the question is the same and MScapin is on the same works.)
Hello everyone, i have now my rpm for syncthing, the installation work well and syncthing too, but now i have to do the createlinks for my SMESERVER-SYNCTHING, in it i need my template, and some configuration files (getting the web app of syncthing in the server-manager)
I used all the work of Eloi Nicolas of this bugz : http://bugs.contribs.org/show_bug.cgi?id=8831
Got all the files i need, but i don't even know how to create these create link, i read the docs, but i don't understand them.
Maybe you guys got an easier docs or can explain to me ?
Sorry my english, i'm not good at all...
Best regards,
Dimitri.
-
Steph, I'm actually trying to create the createlinks file and I saw yours for Roundcube (https://github.com/stephdl/smeserver-roundcube/blob/master/createlinks).
Could you explain what is done in this createlinks file ?
What should I put in mine ?
Thanks alot ! :)
the createlinks is there to make links to
services (restart, sigusr1,reload... following an event , for example roundcube-update)
templates(do an expand-template following an event, for example roundcube-update)
actions (launch an action (it can be a perl/bash script for doign something, after/before the template-expand or after the service triggered following an event, for example roundcube-update) :
number <10 (action launched before template expansion)
number >=10<90 after template-expansion and before service triggered
number >90 action launched after service triggered
(may someone can confirm this please)
You need to make a plan of what you need, take a look of all your template2expand, services and actions to launch, but you have some mandatory events in sme. All your new event/template/service in createlinks should be tied to bootstrap-console-save (which is an event called during the reconfiguration of your server) and your new event.
Eventually you can use post-upgrade but I rather prefer to use bootstrap
What I try to do when I do an event roundcube-update, is to avoid the need to reconfigure my server, all actions,templates,services are adjusted accordingly to avoid to reboot the server.
In fact I hate to restart the server.....
However you can't use the same function in the createlinks for roundcube-update and bootstrap-console-save because a lot of actions,services and templates are already tied to this last event, so you need to look in that event and determine what are your needs
-
Got all the files i need, but i don't even know how to create these create link, i read the docs, but i don't understand them.
Maybe you guys got an easier docs or can explain to me ?
A (good) developer should never read the documentation, he should always read the code....I'm kidding...I go out
you have this
http://wiki.contribs.org/Esmith::Build::CreateLinks
http://wiki.contribs.org/Createlinks_example_script
https://github.com/stephdl?tab=repositories
this is what it is done with roundcube-update, like you can see...it is links, blank files and actions launched following the event roundcube-update (signal-event roundcube-update)
[root@sme9dev64-5 ~]# ll -R /etc/e-smith/events/roundcube-update/
/etc/e-smith/events/roundcube-update/:
total 8
lrwxrwxrwx 1 root root 28 17 juin 21:57 S20qmail-update-user -> ../actions/qmail-update-user
drwxr-xr-x 2 root root 4096 17 juin 21:57 services2adjust
drwxr-xr-x 4 root root 4096 17 juin 21:57 templates2expand
/etc/e-smith/events/roundcube-update/services2adjust:
total 0
lrwxrwxrwx 1 root root 7 17 juin 21:57 dovecot -> restart
lrwxrwxrwx 1 root root 7 17 juin 21:57 httpd-e-smith -> sigusr1
lrwxrwxrwx 1 root root 7 17 juin 21:57 mysql.init -> restart
lrwxrwxrwx 1 root root 7 17 juin 21:57 qmail -> restart
/etc/e-smith/events/roundcube-update/templates2expand:
total 8
drwxr-xr-x 6 root root 4096 17 juin 21:57 etc
drwxr-xr-x 3 root root 4096 17 juin 21:57 usr
/etc/e-smith/events/roundcube-update/templates2expand/etc:
total 16
drwxr-xr-x 2 root root 4096 17 juin 21:57 dovecot
drwxr-xr-x 3 root root 4096 17 juin 21:57 e-smith
drwxr-xr-x 3 root root 4096 17 juin 21:57 httpd
drwxr-xr-x 2 root root 4096 17 juin 21:57 roundcubemail
/etc/e-smith/events/roundcube-update/templates2expand/etc/dovecot:
total 0
-rw-r--r-- 1 root root 0 2 avril 02:06 dovecot.conf
/etc/e-smith/events/roundcube-update/templates2expand/etc/e-smith:
total 4
drwxr-xr-x 3 root root 4096 17 juin 21:57 sql
/etc/e-smith/events/roundcube-update/templates2expand/etc/e-smith/sql:
total 4
drwxr-xr-x 2 root root 4096 17 juin 21:57 init
/etc/e-smith/events/roundcube-update/templates2expand/etc/e-smith/sql/init:
total 0
-rw-r--r-- 1 root root 0 2 avril 02:06 80roundcube
/etc/e-smith/events/roundcube-update/templates2expand/etc/httpd:
total 4
drwxr-xr-x 2 root root 4096 17 juin 21:57 conf
/etc/e-smith/events/roundcube-update/templates2expand/etc/httpd/conf:
total 0
-rw-r--r-- 1 root root 0 2 avril 02:06 httpd.conf
/etc/e-smith/events/roundcube-update/templates2expand/etc/roundcubemail:
total 0
-rw-r--r-- 1 root root 0 2 avril 02:06 config.inc.php
/etc/e-smith/events/roundcube-update/templates2expand/usr:
total 4
drwxr-xr-x 3 root root 4096 17 juin 21:57 share
/etc/e-smith/events/roundcube-update/templates2expand/usr/share:
total 4
drwxr-xr-x 3 root root 4096 17 juin 21:57 roundcubemail
/etc/e-smith/events/roundcube-update/templates2expand/usr/share/roundcubemail:
total 4
drwxr-xr-x 4 root root 4096 17 juin 21:57 plugins
/etc/e-smith/events/roundcube-update/templates2expand/usr/share/roundcubemail/plugins:
total 8
drwxr-xr-x 2 root root 4096 17 juin 21:57 managesieve
drwxr-xr-x 2 root root 4096 17 juin 21:57 sieverules
/etc/e-smith/events/roundcube-update/templates2expand/usr/share/roundcubemail/plugins/managesieve:
total 0
-rw-r--r-- 1 root root 0 2 avril 02:06 config.inc.php
/etc/e-smith/events/roundcube-update/templates2expand/usr/share/roundcubemail/plugins/sieverules:
total 0
-rw-r--r-- 1 root root 0 2 avril 02:06 config.inc.php