Po pierwsze instalujemy:
sudo apt-get install tmuxTworzymy plik
sudo nano /etc/init.d/openwebrxi wklejamy do niego
#!/bin/bash### BEGIN INIT INFO# System Required: CentOS/Debian/Ubuntu (32bit/64bit)# Description: Manager for OpenWebRX, Written by Yukiho Kikuchi# Author: Yukiho Kikuchi# Provides: OpenWebRX# Required-Start: $network $local_fs $remote_fs# Required-Stop: $network $local_fs $remote_fs# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Description: Open source, multi-user SDR receiver software with a web interface### END INIT INFONAME="OpenWebRX"NAME_BIN="openwebrx"Info_font_prefix="\033[32m" && Error_font_prefix="\033[31m" && Info_background_prefix="\033[42;37m" && Error_background_prefix="\033[41;37m" && Font_suffix="\033[0m"RETVAL=0check_running(){ PID=`ps -ef |grep "${NAME_BIN}" |grep -v "grep" |grep -v "init.d" |grep -v "service" |awk '{print $2}'` if [[ ! -z ${PID} ]]; then return 0 else return 1 fi}do_start(){ check_running if [[ $? -eq 0 ]]; then echo -e "${Info_font_prefix}[Info]${Font_suffix} $NAME Has been running..." && exit 0 else ulimit -n 51200 tmux new -d -s openwebrx-session 'bash -c "cd /home/openwebrx; ./openwebrx.py; bash"' sleep 2s check_running if [[ $? -eq 0 ]]; then echo -e "${Info_font_prefix}[Info]${Font_suffix} $NAME Start successed!" else echo -e "${Error_font_prefix}[Error]${Font_suffix} $NAME Failed to start!" fi fi}do_stop(){ check_running if [[ $? -eq 0 ]]; then kill -9 ${PID} RETVAL=$? if [[ $RETVAL -eq 0 ]]; then echo -e "${Info_font_prefix}[Info]${Font_suffix} $NAME Stop successed!" else echo -e "${Error_font_prefix}[Error]${Font_suffix}$NAME Failed to stop!" fi else echo -e "${Info_font_prefix}[Info]${Font_suffix} $NAME isn't running!" RETVAL=1 fi}do_status(){ check_running if [[ $? -eq 0 ]]; then echo -e "${Info_font_prefix}[Info]${Font_suffix} $NAME has been running..." echo -e "${Info_font_prefix}[Info]${Font_suffix} Listed PID:\n${PID}" else echo -e "${Info_font_prefix}[Info]${Font_suffix} $NAME isn't running!" RETVAL=1 fi}do_restart(){ do_stop do_start}case "$1" in start|stop|restart|status) do_$1 ;; *) echo "Usage: $0 { start | stop | restart | status }" RETVAL=1 ;;esacexit $RETVALNie zapomnij zmienić linijkę odpowiadającą za położenie pliku w /home/user
Nadajemy mu uprawnienia:
sudo chmod +x /etc/init.d/openwebrxedytujemy /etc/rc.local, dodając tę linijkę przed exit 0
sudo /etc/init.d/openwebrx startSprawdzamy czy OpenWebRX się uruchamia po restarcie.
By sprawdzić czy OpenWebRX się uruchamia jako usługaużywamy
sudo /etc/init.d/openwebrx status
sudo /etc/init.d/openwebrx restartsudo /etc/init.d/openwebrx stop