Een heldere handleiding hoe je zo iets opzet zou ook al volstaan.
Niet zo heel moeilijk. Begin met een openplotter image dan heb je al een werkende signal-k server.
Dan headless opstarten, inloggen met ssh en de sd card read-only maken.
Dan een klein shellscript maken dat de overgaat naar rw en de X-serveropstart. Ik heb dit simpel "X" genoemd.
En tenslotten een startup script dat een gemodificeerde openplotter opstart zonder grafische dingetjes. Heb ik "start_no_x" genoemd
#!/usr/bin/python
# This file is part of Openplotter.
# Copyright (C) 2015 by sailoog <https://github.com/sailoog/openplotter>
# e-sailing <https://github.com/e-sailing/openplotter>
# Openplotter is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# any later version.
# Openplotter is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Openplotter. If not, see <http://www.gnu.org/licenses/>.
import wx, subprocess, time, os, threading, sys, platform, requests, ConfigParser, io, json
from shutil import copyfile
from classes.conf import Conf
from classes.language import Language
from classes.SK_settings import SK_settings
def starting():
conf = Conf()
home = conf.home
op_folder = conf.op_folder
conf_folder = conf.conf_folder
print('starting ;-)')
delay=int(conf.get('STARTUP', 'delay'))
opencpn=conf.get('STARTUP', 'opencpn')
opencpn_no=conf.get('STARTUP', 'opencpn_no_opengl')
opencpn_fullscreen=conf.get('STARTUP', 'opencpn_fullscreen')
play=conf.get('STARTUP', 'play')
sound=conf.get('STARTUP', 'sound')
node_red=conf.get('STARTUP', 'node_red')
enable=conf.get('AIS-SDR', 'enable')
gain=conf.get('AIS-SDR', 'gain')
ppm=conf.get('AIS-SDR', 'ppm')
channel=conf.get('AIS-SDR', 'channel')
pypilot_mode=conf.get('PYPILOT', 'mode')
webapp=conf.get('PYPILOT', 'webapp')
webapp_port=conf.get('PYPILOT', 'webapp_port')
N2K_output=conf.get('N2K', 'output')
tools_py=[]
if conf.has_section('TOOLS'):
if conf.has_option('TOOLS', 'py'):
data=conf.get('TOOLS', 'py')
try:
temp_list=eval(data)
except:temp_list=[]
if type(temp_list) is list: pass
else: temp_list=[]
for ii in temp_list:
tools_py.append(ii)
#######################################################
subprocess.call(['pkill', '-f', '/openplotter/openplotter'])
print('Checking Signal K password...')
with open(home+'/.signalk/security.json') as data_file:
data = json.load(data_file)
for i in data['users']:
if i['username'] == 'openplotter' and i['password'] == '$2a$10$quNPtJWG7r1wpEKTHPEjqeiCPXNl3dCTS/D235x92sS2lAgcGCH0O':
add_warnings_data(_('\n\nSecurity warning: You are using the default password for Signal K server (openplotter).\nPlease change password in Signal K > Security > Users > openplotter.'))
print(' See warning.')
else: print(' Done.')
print('\nChecking Signal K defaults...')
sk_settings = SK_settings()
check_start('signalk-server')
if platform.machine()[0:3]=='arm':
print('\nChecking pi password...')
out = subprocess.check_output(['sudo', '-n', 'grep', '-E', '^pi:', '/etc/shadow'])
tmp = out.split(':')
passw_a = tmp[1]
tmp = passw_a.split('$')
salt = tmp[2]
passw_b = subprocess.check_output(['mkpasswd', '-msha-512', 'raspberry', salt])
if passw_a.rstrip() == passw_b.rstrip():
add_warnings_data(_('\n\nSecurity warning: You are using the default password for "pi" user (raspberry).\nPlease change password in Menu > Preferences > Raspberry Pi Configuration.'))
print(' See warning.')
else: print(' Done.')
wifi_default = conf_folder + '/Network/default'
if not os.path.isdir(wifi_default):
print('\nChecking WIFI Access Point password...')
wifi_pass = ''
try:
hostapd = open('/etc/hostapd/hostapd.conf', 'r')
data = hostapd.read()
hostapd.close()
i=data.find("wpa_passphrase")
if i>=0:
j=data[i:].find("\n")
if j==0:j=data[i:].length
line = data[i:i+j]
sline = line.split('=')
if len(sline)>1:
wifi_pass=sline[1]
except: pass
if wifi_pass == '12345678':
add_warnings_data(_('\n\nSecurity warning: You are using the default WIFI Access Point password.\nPlease change password in OpenPlotter > Network.'))
print(' See warning.')
else:
print(' Done.')
if delay!=0:
print('\nApplying ')
time.sleep(delay)
print(' Done.')
subprocess.call(['pkill', '-f', 'mqtt_d.py'])
print('\nStarting MQTT server...')
subprocess.Popen(['python', op_folder+'/mqtt_d.py'])
check_start('mqtt_d.py')
subprocess.call(['pkill', '-f', '1w_d.py'])
print('\nStarting 1W sensors...')
subprocess.Popen(['python', op_folder+'/1w_d.py'])
check_start('1w_d.py')
subprocess.call(['pkill', '-f', 'diagnostic-N2K-output.py'])
subprocess.call(['pkill', '-f', 'N2K-server_d.py'])
if N2K_output == '1':
print('\nStarting N2K server...')
subprocess.Popen(['python', op_folder+'/N2K-server_d.py'])
check_start('N2K-server_d.py')
subprocess.call(['pkill', '-f', 'SK-base_d.py'])
print('\nStarting actions and NMEA 0183/N2K generators...')
subprocess.Popen(['python', op_folder+'/SK-base_d.py'])
check_start('SK-base_d.py')
if util_process_exist('node-red'):
subprocess.call('node-red-stop')
if node_red=='1':
print('\nStarting Node-RED...')
try:
subprocess.Popen('node-red-start')
check_start('node-red')
except: pass
subprocess.call(['pkill', '-f', 'read_sensors_d.py'])
print('\nStarting I2C, SPI, GPIO and Pypilot...')
subprocess.Popen(['python', op_folder+'/read_sensors_d.py'], cwd=home + '/.pypilot')
check_start('read_sensors_d.py')
subprocess.call(['pkill', '-f', 'pypilot_webapp'])
if webapp=='1' and pypilot_mode == 'basic autopilot':
print('\nStarting Pypilot Web App...')
try: subprocess.Popen(['pypilot_webapp', webapp_port])
except: pass
check_start('pypilot_webapp')
subprocess.call(['pkill', '-9', 'aisdecoder'])
subprocess.call(['pkill', '-9', 'rtl_fm'])
if enable=='1':
print('\nStarting SDR AIS reception...')
frecuency='161975000'
if channel=='b': frecuency='162025000'
rtl_fm=subprocess.Popen(['rtl_fm', '-f', frecuency, '-g', gain, '-p', ppm, '-s', '48k'], stdout = subprocess.PIPE)
aisdecoder=subprocess.Popen(['aisdecoder', '-h', '127.0.0.1', '-p', '10110', '-a', 'file', '-c', 'mono', '-d', '-f', '/dev/stdin'], stdin = rtl_fm.stdout)
check_start('aisdecoder')
subprocess.call(['pkill', '-9', 'kplex'])
print('\nStarting NMEA 0183 Multiplexer...')
subprocess.Popen('kplex')
check_start('kplex')
#print('\nStarting Tools...')
#index=0
#for i in tools_py:
#folder = tools_py[index][2]
#file = folder+'.py'
#if i[3]=='1':
#subprocess.call(['pkill', '-9', file])
#if os.path.isfile(conf_folder+'/tools/'+folder+'/'+file):
#subprocess.Popen(['python',conf_folder+'/tools/'+folder+'/'+file])
#else:
#subprocess.Popen(['python',op_folder+'/tools/'+folder+'/'+file])
#index+=1
#print(' Done.')
#subprocess.call(['pkill', '-9', 'mpg123'])
#if play=='1':
#if sound:
#try: subprocess.Popen(['mpg123', '-q', sound])
#except: pass
def check_start(process):
time.sleep(2)
if util_process_exist(process):
print(' Done.')
else:
print(' Not Started.')
def util_process_exist(process_name):
pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
exist = False
for pid in pids:
try:
if process_name in open(os.path.join('/proc', pid, 'cmdline'), 'rb').read():
exist = True
except IOError: # proc has already terminated
continue
return exist
def print_help():
print('This is a part of OpenPlotter software')
print('It starts all needed server/services/background processes')
print('Options are:')
print('startup start')
print('startup stop')
print('this: startup -h')
if len(sys.argv)>1:
if sys.argv[1]=='stop':
subprocess.call(['sudo', 'systemctl', 'stop', 'signalk.service'])
subprocess.call(['sudo', 'systemctl', 'stop', 'signalk.socket'])
subprocess.call(['pkill', '-9', 'opencpn'])
subprocess.call(['pkill', '-9', 'kplex'])
if util_process_exist('node-red'):
subprocess.call('node-red-stop')
subprocess.call(['pkill', '-9', 'aisdecoder'])
subprocess.call(['pkill', '-9', 'rtl_fm'])
subprocess.call(['pkill', '-f', '1w_d.py'])
subprocess.call(['pkill', '-f', 'read_sensors_d.py'])
subprocess.call(['pkill', '-f', 'pypilot_webapp'])
subprocess.call(['pkill', '-f', 'mqtt_d.py'])
subprocess.call(['pkill', '-f', 'SK-base_d.py'])
subprocess.call(['pkill', '-f', 'N2K-server_d.py'])
subprocess.call(['pkill', '-f', '/openplotter/openplotter'])
subprocess.call(['killall', 'diagnostic-'])
elif sys.argv[1]=='start':
starting()
elif sys.argv[1]=='-h': print_help()
else: print_help()
That's it. Dan start dus openplotter op zonder grafische schil maar met alle tools.
en als je in je ssh login "X" intikt start dus de grafische schil incl openplotter en kan je met vnc allen veranderen. Netjes afsluiten zodat het op de sd-kaart wordt weggeschreven, en klaar.