Commit df6cab6f authored by Éloïs's avatar Éloïs
Browse files

Merge branch 'StartUp' into '1.6'

Add startup scripts

See merge request nodes/typescript/duniter!1224
parents 02fe3188 16e94037
......@@ -16,8 +16,8 @@ export const WS2PDependency = {
cliOptions: [
{ value: '--ws2p-upnp', desc: 'Use UPnP to open remote port.' },
{ value: '--ws2p-noupnp', desc: 'Do not use UPnP to open remote port.' },
{ value: '--ws2p-host <host>', desc: 'Port to listen to.' },
{ value: '--ws2p-port <port>', desc: 'Host to listen to.', parser: (val:string) => parseInt(val) },
{ value: '--ws2p-host <host>', desc: 'Host to listen to.' },
{ value: '--ws2p-port <port>', desc: 'Port to listen to.', parser: (val:string) => parseInt(val) },
{ value: '--ws2p-remote-host <address>', desc: 'Availabily host.' },
{ value: '--ws2p-remote-port <port>', desc: 'Availabily port.', parser: (val:string) => parseInt(val) },
{ value: '--ws2p-remote-path <path>', desc: 'Availabily web path.' },
......
......@@ -500,6 +500,7 @@ function commandLineConf(program:any, conf:any = {}) {
if (cli.currency) conf.currency = cli.currency;
if (cli.server.port) conf.port = cli.server.port;
if (cli.cpu) conf.cpu = Math.max(0.01, Math.min(1.0, cli.cpu));
if (cli.nbCores) conf.nbCores = Math.max(1, Math.min(ProverConstants.CORES_MAXIMUM_USE_IN_PARALLEL, cli.nbCores));
if (cli.prefix) conf.prefix = Math.max(ProverConstants.MIN_PEER_ID, Math.min(ProverConstants.MAX_PEER_ID, cli.prefix));
if (cli.logs.http) conf.httplogs = true;
if (cli.logs.nohttp) conf.httplogs = false;
......
......@@ -167,6 +167,19 @@ tar czf "${BIN}/duniter-desktop-${DUNITER_TAG}-linux-x64.tar.gz" * || exit 1
# Build Debian packages
# -----------------------
# Parameters
# 1: Building directory.
build_extra_desktop() {
cp -r "${ROOT}/release/extra/desktop/"* "${1}" || exit 1
}
# Parameters
# 1: Building directory.
build_extra_server() {
mkdir -p "${1}/lib/systemd/system" || exit 1
cp "${ROOT}/release/extra/systemd/duniter.service" "${1}/lib/systemd/system" || exit 1
}
# Parameters
# 1: either "server" or "desktop".
# 2: package name for Debian.
......@@ -174,9 +187,7 @@ build_deb_pack() {
rm -rf "${RELEASES}/duniter-x64"
mkdir "${RELEASES}/duniter-x64" || exit 1
cp -r "${ROOT}/release/extra/debian/package/"* "${RELEASES}/duniter-x64" || exit 1
if [[ "${1}" == "desktop" ]]; then
cp -r "${ROOT}/release/extra/desktop/"* "${RELEASES}/duniter-x64" || exit 1
fi
build_extra_${1} "${RELEASES}/duniter-x64"
mkdir -p "${RELEASES}/duniter-x64/opt/duniter/" || exit 1
chmod 755 "${RELEASES}/duniter-x64/DEBIAN/"post* || exit 1
chmod 755 "${RELEASES}/duniter-x64/DEBIAN/"pre* || exit 1
......
......@@ -34,6 +34,10 @@ if [[ -d $DUN_SOURCES/node ]]; then
cd $DUN_SOURCES
cd node/bin/
ln -s ../lib/node_modules/npm/bin/npm-cli.js ./npm -f
# Add duniter user for service
mkdir -p /var/lib/duniter
adduser --system --quiet --home /var/lib/duniter --no-create-home --disabled-password --group duniter
chown duniter:duniter /var/lib/duniter
fi
# Else will execute with environment node
......
# File containing crypto keys
#DUNITER_KEYS=/etc/duniter/keys.yml
# Uncomment the following line to start the web GUI
#DUNITER_WEB=yes
# Parameters for the web GUI
#DUNITER_WEB_HOST=localhost
#DUNITER_WEB_PORT=9220
# User and group of running process
#DUNITER_GROUP=duniter
#DUNITER_USER=duniter
# Directory of duniter files
#DUNITER_HOME=/var/lib/duniter
# Directory of duniter data
#DUNITER_DATA=duniter_default
#!/sbin/openrc-run
: ${DUNITER_GROUP:=duniter}
: ${DUNITER_USER:=duniter}
: ${DUNITER_HOME:=/var/lib/duniter}
: ${DUNITER_DATA:=duniter_default}
command="/usr/bin/duniter"
if yesno "${DUNITER_WEB}"; then
command_args="webstart"
if [[ ! -z ${DUNITER_WEB_HOST} ]]; then
command_args="${command_args} --webmhost \"${DUNITER_WEB_HOST}\""
fi
if [[ ! -z ${DUNITER_WEB_PORT} ]]; then
command_args="${command_args} --webmport \"${DUNITER_WEB_PORT}\""
fi
else
command_args="start"
fi
if [[ ! -z ${DUNITER_KEYS} ]] && [[ -r ${DUNITER_KEYS} ]]; then
command_args="${command_args} --keyfile \"${DUNITER_KEYS}\""
fi
command_args="${command_args} --home \"${DUNITER_HOME}\" --mdb \"${DUNITER_DATA}\" ${DUNITER_SSD_OPTIONS}"
start_stop_daemon_args="--user \"${DUNITER_USER}\":\"${DUNITER_GROUP}\""
description="Duniter node"
depend() {
need net
}
status() {
if ${command} status --home "${DUNITER_HOME}" --mdb "${DUNITER_DATA}" | grep -q "is running"; then
einfo "status: started"
return 0
else
if service_started; then
mark_service_stopped
eerror "status: crashed"
return 32
else
einfo "status: stopped"
return 3
fi
fi
}
stop() {
${command} stop --home "${DUNITER_HOME}" --mdb "${DUNITER_DATA}"
}
[Unit]
Description=Duniter node
After=network.target
[Service]
# Should be set to web in order to start with web GUI
Environment="DUNITER_WEB="
Environment="DUNITER_HOME=/var/lib/duniter"
Environment="DUNITER_DATA=duniter_default"
# If using a key file, DUNITER_OPTS can be defined like so:
#Environment="DUNITER_OPTS=--keyfile /etc/duniter/keys.yml"
Environment="DUNITER_OPTS="
Group=duniter
User=duniter
Type=forking
ExecStart=/usr/bin/duniter ${DUNITER_WEB}start --home ${DUNITER_HOME} --mdb ${DUNITER_DATA} $DUNITER_OPTS
ExecReload=/usr/bin/duniter ${DUNITER_WEB}restart --home ${DUNITER_HOME} --mdb ${DUNITER_DATA} $DUNITER_OPTS
ExecStop=/usr/bin/duniter stop --home ${DUNITER_HOME} --mdb ${DUNITER_DATA}
Restart=on-failure
[Install]
WantedBy=multi-user.target
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment