#!/usr/bin/perl =pod =head1 NAME galeon-service - control interface for the Galeon web browser service =head1 SYNOPSIS /usr/local/bin/galeon-service clean | start | stop | test /usr/local/bin/galeon-service --help | --man =head1 DESCRIPTION I is a control interface for the Galeon web browser service. =cut use strict; use warnings; require Getopt::Long; require Pod::Usage; use lib '/usr/local/lib'; sub _clean(); # # Per 'clean' argument. # sub _shift_options(); # # Shifts command line options into %option. # # ---------------------------------------------------------------------------------------- my %option; _shift_options; =pod =head1 ARGUMENTS =over 8 =cut my $argument = shift; defined $argument or $argument = ''; # prevent warnings # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if( $argument eq 'clean' ) { =pod =item B Cleans up after the service, in case it was not properly stopped on the last run. =cut _clean; exit; } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if( $argument eq 'start' ) { =pod =item B Starts the service. =cut require Zelea::GaleonService; my $command = 'galeon --server >>/tmp/zelea_log 2>&1 &'; system $command and die 'unable to execute: ' . $command; Zelea::GaleonService::set_running( 1 ); exit; } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if( $argument eq 'stop' ) { =pod =item B Stops the service. =cut my $command = 'galeon --quit'; system $command and die 'unable to execute: ' . $command; _clean; exit; } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if( $argument eq 'test' ) { =pod =item B Tests whether the service is running. Exits with status 0 for true; 1 for false. =cut my $true = 0; # for 'test' purposes my $false = 1; my $status = $false; # till proven otherwise require Zelea::GaleonService; Zelea::GaleonService::is_running() and $status = $true; exit $status; } =pod =back =cut Pod::Usage::pod2usage( -verbose => 0 ); # and exits # - S u b - B o d y ---------------------------------------------------------------------- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sub _clean() { require Zelea::GaleonService; my $command = 'rm -f ~/.galeon/session_*.xml'; # otherwise, it will pop a dialog for crash recovery next time it starts system $command and die 'unable to execute: ' . $command; Zelea::GaleonService::set_running( 0 ); } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sub _shift_options() { my @specification; =pod =head1 OPTIONS =over 8 =cut push @specification, 'help|?'; =pod =item --B Prints a brief help message and exits. =cut push @specification, 'man'; =pod =item --B Prints the full manual page and exits. =cut Getopt::Long::GetOptions( \%option, @specification ) or Pod::Usage::pod2usage( -verbose => 0 ); # and exits =pod =back =cut Pod::Usage::pod2usage( -verbose => 1 ) if defined $option{'help'}; # and exits Pod::Usage::pod2usage( -verbose => 2 ) if defined $option{'man'}; # and exits } __END__ =pod =head1 AUTHOR Michael Allan =cut