Nothing to get excited about as this is just a beginning of my first
Perl script. Intention is to pipe it from some web accessible location
to perl upon first boot.
I have difficulties with 'perlism' as I tend to only write small trivial
shell scripts.
More specifically, the following line:
foreach (@packages) { qx/pkg_add $_/; }
Surely this is not an appropriate way for invoking interactive
system command to install packages? Would love to rewrite that. E.g.
I might add some interactive options to `pkg_add` which would render
this useless.
Next up, I need to *append* the following
$DUID.a /storage ffs rw,nodev,nosuid,softdep 1 2
to `/etc/fstab` and am a bit lost as to what is the best way to
accomplish that. I could just echo it but then again I could just write
the whole thing in sh in the first place.
Also this:
my $DUID = qx/disklabel -n sd3 | grep duid | cut -d : -f 2/;
$DUID =~ s/^\s+|\s+$//;
Could get rewritten more natively? With the grep and cut parts in Perl?
These are just beginnings, at least one more function is needed for
putting all the configuration files from the storage volume to various
places in /etc and my home directory.
Any other comments for improvements are more than welcome. Thanks.
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
die "This script must be run as root.\n" unless $> eq 0;
my $arch = qx/machine/;
chomp $arch;
$ENV{PKG_PATH} = "http://obsd.si/pub/OpenBSD/snapshots/packages/$arch/";
sub install_packages {
my @packages = qw/
ImageMagick--
adsuck
antiword
autocutsel
btpd
cantarell-fonts
dtach
fdm
git
gtk2-rezlooks-engine
inconsolata-font
ledger
mercurial
mpg123
mplayer
mupdf
mutt-1.5.21p0v0--
p5-Text-Autoformat
p5-ack
p7zip-rar
perltidy
pngcrush
py-virtualenv
ratpoison
rsync--
rxvt-unicode
unclutter
vorbis-tools
w3m--
xcursor-dmz
xxxterm
/;
foreach (@packages) { qx/pkg_add $_/; }
}
sub mount_raid {
my $DUID = qx/disklabel -n sd3 | grep duid | cut -d : -f 2/;
$DUID =~ s/^\s+|\s+$//;
# "$DUID.a /storage ffs rw,nodev,nosuid,softdep 1 2\n"
system('mount', '/storage');
}
#say 'Installing packages.';
#install_packages();
#say 'Done.';
#say '';
#say 'Mounting storage RAID.';
#mount_raid();
#say 'Done.';
#say '';
#say 'Configuring system.';
#configure_system();
#say 'Done.';
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/