guides:unix_advanced_setup
Table of Contents
Advanced setup
This guide was tested on clean installation of Debian GNU/Linux 8.1. Should be same or very similar on other Linux distributions.
Running on ports 1024 and below without Root
- a. Install file capabilites with command: apt-get install libcap2-bin
- b. You can set capabilities to run on ports 1024 and below manually or use makefile to set them.
Set PtokaX capabilities manually with command: setcap 'cap_net_bind_service=+ep' PtokaX
Or simply install PtokaX with command: make install
Creating unprivileged user for PtokaX and run PtokaX on system startup
We assume that you installed PtokaX binary with command: make install
- a. Create new home directory for new user with command: mkdir /home/ptokax
- b. Create new user for PtokaX with command: adduser –system –group –home /home/ptokax –no-create-home –disabled-login ptokax
- c. Move PtokaX config files to /home/ptokax/
- d. Set ownership to PtokaX user for that directory and it's content with command: chown -R ptokax:ptokax /home/ptokax/
- e. Copy init script from PtokaX source to /etc/init.d/ directory
When you have PtokaX with SQLite or without database then use this command: cp init_script /etc/init.d/ptokax
When you have PtokaX with PostgreSQL then use this command: cp init_script_postgres /etc/init.d/ptokax
When you have PtokaX with MySQL or MariaDB then use this command: cp init_script_mysql /etc/init.d/ptokax - f. Move to /etc/init.d directory with command: cd /etc/init.d
Make our init script executable with command: chmod +x ptokax
And install this init script with command: update-rc.d ptokax defaults - g. Now PtokaX should start with system start. If you want, then you can test if PtokaX can start with this script using command: /etc/init.d/ptokax start
Multiple PtokaX instances starting with system
This is similar as above. But we need one settings directory and one init script per instance. So we have /home/ptokax directory and user ptokax who owns it (created with a and b above).
- a. Create new subdirectory (for this example i'm using px1) with command: mkdir /home/ptokax/px1
- b. Move PtokaX config files to /home/ptokax/px1/
- c. Set ownership to PtokaX user for that directory and it's content with command: chown -R ptokax:ptokax /home/ptokax/px1
- d. Copy init script from PtokaX source to /etc/init.d/ directory
When you have PtokaX with SQLite or without database then use this command: cp init_script /etc/init.d/px1
When you have PtokaX with PostgreSQL then use this command: cp init_script_postgres /etc/init.d/px1
When you have PtokaX with MySQL or MariaDB then use this command: cp init_script_mysql /etc/init.d/px1 - e. Open init script in text editor with this command (i'm using Vi because is available on most Unixes preinstalled): vi px1
Change PtokaX settings path PTOKAX_PATH=/home/$PTOKAX_USER/ to PTOKAX_PATH=/home/$PTOKAX_USER/px1/ and PtokaX PID file PTOKAX_PID=/home/$PTOKAX_USER/PtokaX.pid to PTOKAX_PID=/home/$PTOKAX_USER/px1/PtokaX.pid - f. Move to /etc/init.d directory with command: cd /etc/init.d
Make our init script executable with command: chmod +x px1
And install this init script with command: update-rc.d px1 defaults - g. Now PtokaX using px1 directory and init script should start with system start. If you want, then you can test if PtokaX can start with this script using command: /etc/init.d/px1 start
- h. Repeat and use another directory/init script name instead of px1 for every PtokaX instance.
guides/unix_advanced_setup.txt · Last modified: 06/07/2015 00:02 by ppk