evilkitty
Posts: 380
Joined: Tue Apr 15, 2014 11:39 pm

[SOLVED] mgetty setup on jessie

Wed Jan 13, 2016 10:04 pm

i have a U.S. Robotics 56k modem that i use for caller id
am i don't know how to get mgetty running on jessie
i have tried this: viewtopic.php?f=66&t=123081#p865954
on wheezy i had this file: /etc/inittab

Code: Select all

# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

# The default runlevel.
id:2:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

# Action on special keypress (ALT-UpArrow).
#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work."

# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop

# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
#  <id>:<runlevels>:<action>:<process>
#
# Note that on most Debian systems tty7 is used by the X Window System,
# so if you want to add more getty's go ahead but skip tty7 if you run X.
#
1:2345:respawn:/sbin/getty --noclear 38400 tty1 
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100

# Example how to put a getty on a modem line.
#
T3:23:respawn:/sbin/mgetty -x 0 /dev/ttyACM0


#Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
and this file: /etc/mgetty/mgetty.config

Code: Select all

#
# mgetty configuration file
#
# this is a sample configuration file, see mgetty.info for details
#
# comment lines start with a "#", empty lines are ignored


# ----- global section -----
#
# In this section, you put the global defaults, per-port stuff is below


# set the global debug level to "4" (default from policy.h)
debug 4

# set the local fax station id
fax-id  

# access the modem(s) with 38400 bps
speed 38400

# use an alternate issue file, to avoid being bitten by linuxlogo
issue-file /etc/issue.mgetty

#  use these options to make the /dev/tty-device owned by "uucp.uucp" 
#  and mode "rw-rw-r--" (0664). *LEADING ZERO NEEDED!*
#port-owner uucp
#port-group uucp
#port-mode 0664

#  use these options to make incoming faxes owned by "root.uucp" 
#  and mode "rw-r-----" (0640). *LEADING ZERO NEEDED!*
#fax-owner root
#fax-group uucp
#fax-mode 0640


# ----- port specific section -----
# 
# Here you can put things that are valid only for one line, not the others
#

# Zoom V.FX 28.8, connected to ttyS0: don't do fax, less logging
#
#port ttyS0
#  debug 3
#  data-only y

# some other Rockwell modem, needs "switchbd 19200" to receive faxes
# properly (otherwise it will fail with "timeout").
#
#port ttyS1
#  speed 38400
#  switchbd 19200

# ZyXEL 2864, connected to ttyS2: maximum debugging, grab statistics
#
#port ttyS2
#  debug 8
#  init-chat "" \d\d\d+++\d\d\dAT&FS2=255 OK ATN3S0=0S13.2=1 OK 
#  statistics-chat "" AT OK ATI2 OK
#  statistics-file /var/log/statistics.ttyS2
#  modem-type cls2

# direct connection of a VT100 terminal which doesn't like DTR drops
# ("direct" meaning "*no* *modem*".  NEVER enable "direct yes" on modem lines!)
#
#port ttyS3
#  direct y
#  speed 19200
#  toggle-dtr n
port ttyACM0
  rings 2
  init-chat "" AT#CID=1
  cnd-program /usr/local/sbin/callerID
and here is my script (files are stored on ram in a directory setup for apache2 to allow a HTTP to read them):
/usr/local/sbin/callerID

Code: Select all

#!/usr/bin/php
<?php
$json=(object)array(
	'time'=>time(),
	'num'=>(float)$argv[2],
	'name'=>$argv[3]
);
$names=json_decode(file_get_contents('/opt/callerIDnames.json'));
if(isset($names->{$json->{'num'}})){
	$json->{'name'}=$names->{$json->{'num'}};
}
$file=fopen('/tmp/ram/caller.json','w+');
fwrite($file,json_encode($json));
fclose($file);
$file='/tmp/ram/caller.log.json';
if(file_exists($file))
	$log=json_decode(file_get_contents($file));
else
	$log=array();
array_push($log,$json);
if(count($log)>499)
	array_shift($log);
$file=fopen($file,'w+');
fwrite($file,json_encode($log));
fclose($file);
exit(1);
?>
Last edited by evilkitty on Thu Jan 14, 2016 12:09 am, edited 1 time in total.
My Pi Server: http://imgur.com/a/6xIUI | Thermostat: http://imgur.com/a/4LVnT

evilkitty
Posts: 380
Joined: Tue Apr 15, 2014 11:39 pm

Re: mgetty setup on jessie

Thu Jan 14, 2016 12:08 am

Ok i managed to figure it out with more digging on systemd
i needed to make this file: /lib/systemd/system/mgetty.service

Code: Select all

[Unit]
Description=Smart Modem Getty(mgetty)
Documentation=man:mgetty(8)
Requires=systemd-udev-settle.service
After=systemd-udev-settle.service

[Service]
Type=simple
ExecStart=/sbin/mgetty -x 0 /dev/ttyACM0
Restart=always
PIDFile=/var/run/mgetty.pid.ttyACM0

[Install]
WantedBy=multi-user.target
then i needed a link:

Code: Select all

sudo ln -s /lib/systemd/system/mgetty.service /etc/systemd/system/mgetty.service
then i could start the service:

Code: Select all

sudo systemctl start mgetty.service
edit: seems this is needed to make it autostart (not sure if it works at this time)

Code: Select all

sudo systemctl enable mgetty.service
My Pi Server: http://imgur.com/a/6xIUI | Thermostat: http://imgur.com/a/4LVnT

Aismel
Posts: 1
Joined: Fri Mar 31, 2017 6:27 pm

Re: [SOLVED] mgetty setup on jessie

Fri Mar 31, 2017 7:11 pm

Hi,

Sorry for answer this old topic but I was wondering if you can help making script to limit the time of time login from X user...

Let say Juan have 3 hours daily i suppous need grab the login in and login out and calculate the time online and add until the time pass 3h...

any idea

Etch4
Posts: 2
Joined: Tue Sep 03, 2019 11:05 pm

Re: [SOLVED] mgetty setup on jessie

Tue Sep 03, 2019 11:21 pm

make this file: /lib/systemd/system/mgetty.service
ln -s /lib/systemd/system/mgetty.service /etc/systemd/system/mgetty.service
systemctl enable mgetty.service
reboot

Thank You very very much
This is F...... amazing
Fast, Reliable.

Etch4
Posts: 2
Joined: Tue Sep 03, 2019 11:05 pm

Re: [SOLVED] mgetty setup on jessie

Wed Sep 04, 2019 9:38 am

I needed it for Elementary OS.
In Your mgetty.sevice file,
I changed /dev/ttyACM0 to /dev/ttyS0 .
That's all.
Grtzzz Etch4 to evilkitty

Return to “Raspberry Pi OS”