I was searching this site for good answer to my question, the best I could find was this. (I'd guess to put my config in /etc
, application in /usr/local/bin
and data in either /home/firda/.tunnel
or somewhere in /var
or /srv
or /usr
.)
Preface:
I am writing server application in C++. It should stand inbetween other servers, mobile applications and units (small devices e.g. in car). It would generally listen on TCP port (to handle clients = mobile appplications and servers) and UDP port (where data would go from/to ipsec/racoon and/or open port - communication with devices, custom protocol). It does not need root's privileges (port > 1000, e.g. 11235), so, I have decided to set SUID bit and assign the ownership to my account (to make it run under my account even if I start it as root). This is how I deploy it now (from MAKEFILE)
deploy := /usr/local/bin
user := firda
name := tunnel
watchdog := tunnel-watchdog
names := $(name) $(watchdog)
deploy:
cp $(names) $(deploy)/
chown $(user):$(user) $(patsubst %,$(deploy)/%,$(names))
chmod a-rwx,u+xs $(patsubst %,$(deploy)/%,$(names))
$(deploy)/$(watchdog)
and added /usr/local/bin/tunnel-watchdog
to /etc/rc.local
(tunnel-watchdog just forks to run tunnel and restart it if it dies). When I want to deploy it, I copy the sources to my home directory (/home/firda/tunnel
), type make test
to build and self-test it (under non-root account), then kill
those two running processes (after ps -fu firda
to know PIDs) and type make deploy
to copy new executables to /usr/local/bin
and start it again (under root account).
Questions:
- Where to place basic configuration? (
/etc/tunnel/config
now - specifies port numbers, but now it holds user/unit credentials/settings as well) - Where to place basic runtime configuration-like data (user names, credentials, passwords, cipherkeys, device IDs - all can be remotedly changed by custom TCP protocol). (for now
/etc/tunnel/config.tmp
is created after some timeout when e.g. user is added,/etc/tunnel/config
->/etc/tunnel/config.bak
and/etc/tunnel/config.tmp
->/etc/tunnel/config
) - Where to place big persistent read-write data? (this is what needs to be done - all data from all units placed in some big file, but no dBase, custom made virtual store -
/home/firda/whatever
?/srv/something
?)
I know I could place all the files in my home directory (it is my own server which probably won't get distributed to anybody else, ...who knows), but would like to know best practice advice to do it properly (not to cross administrator habbits like disk partitioning and quotas - I'd like to know how it is usually done, how it can be done, which folders are good for some backup system). Thank you.
P.S.: This is not a web server (so far), but I'd guess that answers could be similar. This question may seem duplicate to the one I linked to, but I was not satisfied with the answer, so, rather specified my own application and needs (the question of partitioning, quotas and backups especially).
FEEDBACK:
Filesystem Hierarchy Standard splits directories according to two criteria: read-only (/usr
, /etc
, /opt
and /boot
) - all these are for executables and stable configiration, not for data. Second criteria is shareable (platform independent) and unshareable (platform dependent). Data should go in /var
tree with one exception added: /srv
can be used for both read-only and read-write data (thus perfect for services that want both type of files in one directory).
For now I will probably use /etc
for basic configuration (including parameters for changing directories to use), /usr/local/bin
for the application and /var/local
for my data. (Using /srv
could be second option.)
Any comments before we can close this question?