Skip to content

Commit

Permalink
Merge pull request #2649 from freenas/issues/76413
Browse files Browse the repository at this point in the history
tkt-76413: Move ix-ttys to etc
  • Loading branch information
sonicaj committed Feb 25, 2019
2 parents a5d79a4 + 267f8c8 commit cfe6f66
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 95 deletions.
89 changes: 0 additions & 89 deletions src/freenas/etc/ix.rc.d/ix-ttys

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
<%
advanced = middleware.call_sync('system.advanced.config')
serial_speed = f'.{advanced["serialspeed"]}' if advanced['serialconsole'] else ''
ttyv = 'freenas' if advanced['consolemenu'] else 'freenas.115200'
ttyu = f'freenas{serial_speed}' if advanced['consolemenu'] else f'3wire{serial_speed}'

# Forcefully enable TTY on configured UART port in case it
# is different from console port. It may happen since we
# can not enable/change serial console port without reboot.
serdev = ''
if advanced['serialconsole']:
dev_serial = list(
filter(
lambda i: i['name'].startswith('uart') and int(i['start'], 16) <= int(advanced['serialport'], 16) < int(i['start'], 16) + i['size'],
middleware.call_sync('device.get_info', 'SERIAL')
)
)
if dev_serial:
serdev = dev_serial[0]['name'].replace('uart', 'ttyu')
%>\
#
# $FreeBSD: src/etc/etc.amd64/ttys,v 1.18.2.1 2009/08/03 08:13:06 kensmith Exp $
# @(#)ttys 5.1 (Berkeley) 4/17/89
Expand Down Expand Up @@ -29,7 +49,7 @@
# when going to single-user mode.
console none unknown off secure
#
ttyv0 "/usr/libexec/getty freenas" xterm onifexists secure
ttyv0 "/usr/libexec/getty ${ttyv}" xterm onifexists secure
# Virtual terminals
ttyv1 "/usr/libexec/getty Pc" xterm onifexists secure
ttyv2 "/usr/libexec/getty Pc" xterm onifexists secure
Expand All @@ -41,10 +61,9 @@ ttyv7 "/usr/libexec/getty Pc" xterm onifexists secure
ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure
# Serial terminals
# The 'dialup' keyword identifies dialin lines to login, fingerd etc.
ttyu0 "/usr/libexec/getty 3wire" vt100 onifconsole secure
ttyu1 "/usr/libexec/getty 3wire" vt100 onifconsole secure
ttyu2 "/usr/libexec/getty 3wire" vt100 onifconsole secure
ttyu3 "/usr/libexec/getty 3wire" vt100 onifconsole secure
% for i in range(4):
ttyu${i} "/usr/libexec/getty ${ttyu}" vt100 ${'onifconsole' if f'ttyu{i}' != serdev else 'on'} secure
% endfor
# Dumb console
dcons "/usr/libexec/getty std.9600" vt100 off secure

Expand Down
6 changes: 6 additions & 0 deletions src/middlewared/middlewared/etc_files/ttys_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os
import signal


async def render(service, middleware):
os.kill(1, signal.SIGHUP)
4 changes: 4 additions & 0 deletions src/middlewared/middlewared/plugins/etc.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ class EtcService(Service):
],
'aliases': [
{'type': 'mako', 'path': 'aliases'}
],
'ttys': [
{'type': 'mako', 'path': 'ttys'},
{'type': 'py', 'path': 'ttys_config'}
]
}

Expand Down
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ async def _start_motd(self, **kwargs):
await self._service("motd", "start", quiet=True, **kwargs)

async def _start_ttys(self, **kwargs):
await self._service("ix-ttys", "start", quiet=True, **kwargs)
await self.middleware.call('etc.generate', 'ttys')

async def _reload_ftp(self, **kwargs):
await self.middleware.call("etc.generate", "ftp")
Expand Down

0 comments on commit cfe6f66

Please sign in to comment.