fonte.pl

Publicado por Carlos Carvalho 14/07/2004

[ Hits: 5.318 ]

Download fonte.pl




Eu sou usuario Slackware, mas na empresa que trabalho usamos RedHat por ser homologado com um software
de gerenciamento laboratorial que comerciamos, antes usavamos Conectiva e Migramos para RedHat, entao foi necessario alterar
uma serie de coisas no "RedHATE" (apenas uma piadinha slacker :) ) entre elas a fonte estilo kbd e mapeamento de teclado.
Para isso fiz o fonte.pl , automatizando esse processo , facilitando a vida de quem precisa fazer essa configuracao a cada RH instalado.

Para var

  



Esconder código-fonte

#!/usr/bin/perl -w
#################################################
#################################################
#################################################
#
# fonte.pl v1.0
#               Programa para automatizar
#             a configuracao de fontes e
#             e teclado no RedHat 8.0
#
# Tue Nov 25 13:47:25 GMT 2003
#
# carlos_lnx@ibest.com.br
#
#################################################
#################################################
#################################################

# ROOT ?
sub perm
{
print ("Voce nao esta identificado como ");
print color("blink"),"ROOT !\n", color("reset");
exit(1);
}
$USER eq "root" or &perm ();

use strict;
use Term::ANSIColor;
use Env;
open STDERR, ">/dev/null";
my $clear_string = `clear`;
print $clear_string;


sub INFO ()
{
print <<EOF






   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %################################################################%
   %################################################################%
   %################################################################%
   %################################################################%
   %################################################################%
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    A partir daqui iremos instalar e configurar o mapeamento/fonte do
   Red Hat 8 para que funcione corretamente com o sistema X.
    Siga as instrucoes e tenha em mao o cd de instalacao do linux
   Conectiva 8 (cd 1).

   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %################################################################%
   %################################################################%
   %################################################################%
   %################################################################%
   %################################################################%
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Tecle "ENTER" para continuar...
EOF
}
print color("bold");
&INFO ();
print color("reset");
my $nada0 = <STDIN>;

if (my $profile = open (PROFILE, ">>/etc/profile") == 0) {
        print "Erro ao abrir /etc/profile, verifique as permissoes.\n";
        exit(1);
}
if (my $i18n = open (I18N, ">/etc/sysconfig/i18n") == 0) {
        print "Erro ao abrir /etc/sysconfig/i18n, verifique as permissoes.\n";
        exit(1);
}

#Inserindo o PERL_BADLANG:
print (PROFILE "# Cleaning out Perl error messages:\n");
print (PROFILE "PERL_BADLANG=0\n");
print (PROFILE "export PERL_BADLANG\n");
close (PROFILE);
print "\n" ; print ("Arquivo /etc/profile editado...                           [");
print color("bold"), "OK", color("reset");
print ("]\n");
sleep(3);

#Editando /etc/sysconfig/i18n:
system("cp /etc/sysconfig/i18n /etc/sysconfig/i18n.SALVO");
print (I18N "LANG=pt_BR\n");
print (I18N "LINGUAS=pt_BR\n");
print (I18N "LC_CTYPE=ISO-8859-1\n");
print (I18N "LC_ALL=pt_BR\n");
print (I18N "SYSFONT=lat1u-16\n");
print (I18N "SYSTERM=linux-lat\n");
close(I18N);

print "\n" ; print ("Arquivo /etc/sysconfig/i18n editado...                    [");
print color("bold"), "OK", color("reset");
print ("]\n\n");
sleep(3);

my $x = system("/usr/bin/id titan >/dev/null");
        if ($x ne 0) {
                open (CONSOLECHARS, ">/tmp/PARAMETROS");
                print (CONSOLECHARS "#Copie a linha abaixo para /etc/rc.d/rc.local:\n");
                print (CONSOLECHARS "loadkeys titan\n");
                print (CONSOLECHARS "#Copie as linhas abaixo para /home/titan/.bash_profile:\n");
                print (CONSOLECHARS "consolechars -f iso09.f16\n");
                print (CONSOLECHARS "consolechars -f cp850-8x16\n");
                close(CONSOLECHARS);
sub X ()
{
print <<EOF





  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %                                                                %
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

                      Usuario X nao existe
        Entao apos cria-lo com o cd de instalacao X
       verifique se a linha:
                        "loadkeys titan"
       esta presente no arquivo "/etc/rc.d/rc.local" e se as linhas:
                        "consolechars -f iso09.f16"
                        "consolechars -f cp850-8x16"
       estao presentes no arquivo "/home/titan/.bash_profile".
        Por garantia essas linhas foram criadas em "/etc/PARAMETROS".

   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %                                                                %
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Tecle "ENTER" para continuar...
EOF
}

print $clear_string;
print color("bold");
&X ();
print color("reset");
my $nada1 = <STDIN>;
        }
print("Agora tenha em maos o cd de instalacao numero 1 do Conectiva Linux 8\n");
system("/usr/bin/eject");
print ("Insira o CD na unidade de cd-rom e tecle \"ENTER\"");
my $nada2 = <STDIN>;
system("/usr/bin/eject -t");
        while (my $dir_existe = system("/bin/mount /mnt/cdrom && /bin/ls /mnt/cdrom/conectiva/RPMS >/dev/null") ne 0) {
                print ("Cd incorreto!\n");
                system("/usr/bin/eject -t");
                print ("Insira o cd correto do Conectiva Linux 8.0\n");
                print ("na unidade de cd-rom...\n");
                print ("Control-c para encerrar o programa.\n");
                system("/usr/bin/eject");
                print ("Insira o CD na unidade de cd-rom e tecle \"ENTER\"");
                my $nada3 = <STDIN>;
        }
system("/bin/rpm -e kbdconfig && /bin/rpm -e kbd");
print ("Pacotes: kbdconfig e kbd removidos...                                  [");
print color("bold"), "OK", color("reset");
print ("]\n");
sleep(2);
system("/bin/rpm -ivh /mnt/cdrom/conectiva/RPMS/console-tools-keymaps-0.3.3-7cl.i386.rpm");
system("/bin/rpm -ivh /mnt/cdrom/conectiva/RPMS/console-tools-0.3.3-7cl.i386.rpm");
system("/bin/rpm -ivh /mnt/cdrom/conectiva/RPMS/console-tools-fonts-0.3.3-7cl.i386.rpm");
print ("console-tools-keymaps-0.3.3-7cl.i386.rpm...                            [");
print color("bold"), "OK", color("reset");
print ("]\n");
print ("console-tools-0.3.3-7cl.i386.rpm...                                    [");
print color("bold"), "OK", color("reset");
print ("]\n");
print ("console-tools-fonts-0.3.3-7cl.i386.rpm...                              [");
print color("bold"), "OK", color("reset");
print ("]\n");
system("/usr/bin/eject");
print ("Pacotes acima instalados...\n");
print ("Tecle \"ENTER\"");
my $nada4 = <STDIN>;
print ("\n\n\n");
print ("Instalacao concluida com sucesso!\n");
exit(0);
#EOF

Scripts recomendados

Role-Playing Script

Índice (Logaritmo Discreto) em Perl

Diminuir ou aumentar o brilho de notebook

MyBF - Interpretador de BrainFuck

Testando a agilidade do sistema de arquivos


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts