#! /usr/bin/perl

# Check if the config files are in /var/lib/minicom.
# If so, move them to /etc.
if ( -f '/var/lib/minicom/minirc.dfl' ) {
	print "Moving config file from /var/lib/minicom to /etc\n";
	chdir('/var/lib/minicom');
	system('mv * /etc');
	rmdir('/var/lib/minicom');
}

if (-f '/etc/minicom.noconf') {
	unlink('/etc/minicom.noconf');
	# Warn the user about some things that will need configuration
	print "\nroot should run minicom with the -s flag to set\n";
	print "the system-wide configuration for Minicom.\n\n";
	print "Users must be added to the ``dialout'' group to allow\n";
	print "access to the modem device.\n\n";

	print <<EOF;
Minicom can use the META (ALT) key as command key. You can specify this by
using the '-m' (meta) option to minicom or by putting it in the configuration
file. If you want to put it in the configuration file, you can _only_ use
minicom on the console, and not on a terminal or in an xterm window.
EOF
	print "\nPut usage of META key in configuration file? [n] ";
	$ans = <STDIN>;
	if ($ans =~ m/^[yY].*/) {
		open (FD, '>>/etc/minirc.dfl');
		print FD "pu escape-key       Escape (Meta)\n";
		close FD;
		print "..OK.\n";
	}
}

print "Minicom configuration complete.\n";

0;
