MSV FM

[email protected]: ~ $
Path : /scripts/
File Upload :
Current < : //scripts/update_local_rpm_versions

#!/usr/local/cpanel/3rdparty/bin/perl

# cpanel - scripts/update_local_rpm_versions       Copyright 2022 cPanel, L.L.C.
#                                                           All rights reserved.
# [email protected]                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use strict;
use warnings;

use Cpanel::RPM::Versions::File ();
use Cpanel::Usage               ();
use Cpanel::SafeDir::MK         ();

# ACTIVATION: remove this activation piece when cPanel on CentOS 7 is officially available #
use Cpanel::ConfigFiles::RpmVersions ();

my $add       = '';
my $edit      = '';
my $del       = '';
my $directory = '';
my $file      = '';
my $key       = 0;
my $section   = 1;
my $value     = '';
my $packages  = '';

my %opts = (
    'directory' => \$directory,
    'file'      => \$file,
    'add'       => \$add,
    'edit'      => \$edit,
    'del'       => \$del,
);

# --add section.key.key value
my $cmdl_regex = {
    'modify' => qr/--                    # -- to begin the command
                   (:?add|edit)          # add or edit
                   \s+                   # one or more spaces
                   (:?\S+?)              # keys
                   \s+                   # one or more spaces
                   (.+?)                 # value is the rest of the provided text.
                   \s*                   # Ignore any trailing spaces
                   $/x,    # end of command

    'delete' => qr/--                    # -- to begin the command
                   (:?del)               # Delete command
                   \s+                   # one or more spaces
                   (:?\S+?)              # keys
                   $/x,    # end of command
};

my $orig_cmdl = join ' ', @ARGV;
my $return    = Cpanel::Usage::wrap_options( \@ARGV, \&usage, \%opts );

exit $return if $return;

$file      ||= $Cpanel::ConfigFiles::RpmVersions::RPM_VERSIONS_FILE;
$directory ||= '/var/cpanel/rpm.versions.d';

if ( !-d $directory ) {
    Cpanel::SafeDir::MK::safemkdir( $directory, '0750' );
}

my $versions = Cpanel::RPM::Versions::File->new( { file => $file, directory => $directory } );

if ( $add || $edit ) {

    if ( $orig_cmdl !~ /$cmdl_regex->{'modify'}/ ) {
        usage();
        exit 1;
    }

    my $cmdl = $add ? $add : $edit;
    my ( $section, $keys, $value ) = parse_cmd($cmdl);

    if ( !$section || !@{$keys} || !defined $value ) {
        usage();
        exit 1;
    }

    my $set_method = "set_$section";
    if ( $versions->can($set_method) ) {
        $value = [ split /\s*\,\s*/, $value ] if $value =~ /\,/;

        my $error = $versions->$set_method( { 'key' => $keys, 'value' => $value } );

        if ($error) {
            print $error . "\n\n";
            usage();
            exit 2;
        }

        $versions->save();
    }
    else {
        print "Section $section does not exist.\n";
        usage();
        exit 1;
    }
    exit(0);

}
elsif ($del) {

    if ( $orig_cmdl !~ /$cmdl_regex->{'delete'}/ ) {
        usage();
        exit 1;
    }

    my ( $section, $keys ) = parse_cmd($del);

    if ( !$section || !$keys ) {
        usage();
        exit 1;
    }

    my $del_method = "delete_$section";
    if ( $versions->can($del_method) ) {
        $versions->$del_method( { 'key' => $keys } );
        $versions->save();
    }
    else {
        print "Section $section does not exist.\n\n";
        usage();
        exit 1;
    }

    exit(0);

}

print "Unknown arguments passed to $0\n\n";
usage();
exit 3;

sub usage {
    my $prog = $0;
    $prog =~ s{^.+/(.+)$}{$1};
    print <<EOF;
Usage: $prog
            <
                --add <section.key> <value> |
                --edit <section.key> <value> |
                --del <section.key>
            >
            [--file <file>]
            [--drectory <directory>]
            [--<help|usage>]

        Where:
          --add:       Add a <value> to <section>.<key>
          --edit:      Edit a <value> in <section>.<key>
          --del:       Delete <section>.<key>
          --file:      Get default values from <file>
                       (Default: $Cpanel::ConfigFiles::RpmVersions::RPM_VERSIONS_FILE)
          --directory: Write output to local.versions in <directory>
                       (Default: /var/cpanel/rpm.versions.d)
          --help:      This display
          --usage:     This display
EOF

    return;
}

sub parse_cmd {
    my ($cmd) = @_;
    my ( $section, @keys ) = split /\./, $cmd;

    my $value;
    $value = $ARGV[-1] if $ARGV[-1] ne $ARGV[0];

    return ( $section, \@keys, $value );
}
Bethany
Bethany
0%

THE FINEST HOTEL NEAR LAKE KIVU

The Perfect Base For You

Required fields are followed by *





EC1A68011

About Us

Delicious Interior With The Pinch Of Everything

Bethany Investment group is Presbyterian church in Rwanda(EPR) company that manage Hotel and Guest house in Karongi (Bethany Hotel), ISANO branch in GIKONDO(Kigali), Kiyovu branch(Kigali), AMIZERO branch(Nyagatare-East) and Gisenyi Branch(Rubavu).

Accomodation

Get a Comfortable Room
Feel The Comfort

Get a comfortable room and feel our hotel’s comfort. Bethany Hotel features a variety of fully furnished rooms with extra space, Executive rooms, Deluxe rooms with a beautiful lake view and garden space, Deluxe rooms, comfort rooms, family rooms and standard rooms at your service.

Standard Single

Services

We Provide Top Class Facility
Especially For You

Beach BBQ Party

Kick back on the beach& and enjoy our berbecue from our masterchef

Breakfast

Kick back at our hotels& enjoy our breakfast from our masterchef

Conference Hall

Kick back at our hotels& enjoy our conference halls from all bethany branches

Enjoy with your partner

Honeymoon Package

80%

Get In Touch

Don’t Miss Any Update

    +

    Search your Room

    Required fields are followed by *