Sunteți pe pagina 1din 4

#--------------------------------------------------------------------------------------------# Installation of Cygwin.

# V1.1 10/12/2007 Martin Aldrin


#--------------------------------------------------------------------------------------------use File::Copy;
use Term::ANSIColor qw(:constants);
use Time::local;
#use strict;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year+=1900;
$cygwinpath = "d:/cygwin";
$startcygwin1 = "$cygwinpath/bin/bash.exe -c \"echo opening and closing cygwin..
.done.\"";
$startcygwin2 = "$cygwinpath/bin/rxvt.exe -sl 65000 -e /bin/bash --login -i \"ec
ho opening and closing cygwin...done.\"";
#$user = $ENV{'USERNAME'};
$user = `$cygwinpath/bin/whoami`; chomp($user);
$permissions
= "$cygwinpath/bin/chmod 755 $cygwinpath/cygwin.bat";
$installbackup = "installbackup";
$date_time = "$year-$mon-$mday\_$hour.$min";
$mkdir = "$cygwinpath/bin/mkdir.exe -p $cygwinpath/tmp/$installbackup/$date_time
";
#CYGWIN.BAT
$cygwinbat ="\@echo off\n
D:
chdir D:\\cygwin\\bin\n
set USER=$user
set HOME=/home/$user
set SHELL=/bin/bash
rxvt -sl 65000 -e /bin/bash --login -i";
#PROFILE
$profile = "export PATH=\"/usr/bin:/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/bin/
X11:/usr/local/sbin:/root/bin:\$PATH\"\n
for i in /etc/profile.d/*.sh ; do
if \[ -f \$i \]; then
. \$i
fi
done
\nexport USER=$user
export HOME=/home/$user
export SHELL=/bin/bash
mkdir -p \$HOME\ncd \$HOME
source \$HOME/.bashrc";
#BASHRC
$bashrc='unset PROMPT_COMMAND
export PS1="\\[\\033[1m\\][\\w]\\\\$\\[\\033[0m\\] "
alias ls="ls -FX"
set -o notify
set -o ignoreeof
shopt -s cdspell
shopt -s cdable_vars
shopt -s checkhash
shopt -s checkwinsize
shopt -s sourcepath
shopt -s histappend

';
$bashrc="$bashrc
export PATH=\$PATH:/home/$user/moshell
";
#INPUTRC
$inputrc = "set bell-style visible
set convert-meta Off
set output-meta On
set input-meta On
set completion-ignore-case on
set completion-query-items 150
set mark-directories on
set visible-stats On
set show-all-if-ambiguous On
set expand-tilde On
\"\\e\[D\": backward-char
\"\\e\[C\": forward-char
\"\\e\[A\": history-search-backward
\"\\e\[B\": history-search-forward
\"\\e\[7~\": beginning-of-line
\"\\e\[8~\": end-of-line
\"\\e\[1~\": beginning-of-line
\"\\e\[4~\": end-of-line
\"\\e\[3~\": delete-char
\"\\e\[2~\": menu-complete
\"\\M-\[2~\": paste-from-clipboard # Insert
\"\\M-q\": menu-complete
\"\\C-d\": delete-char
\"\\C-l\": clear-screen
\"\\C-xdf\": dump-functions
\"\\C-xdv\": dump-variables
\"\\C-xdm\": dump-macros";
#Xdefaults
$xdefaults = "Rxvt*background: Black
Rxvt*foreground: Cyan
Rxvt*saveLines: 65535
Rxvt*termName: xterm
Rxvt*geometry: 144x64+0+0
Rxvt*loginShell: true
Rxvt*font: \"Lucida Console-11\"
Rxvt*cutchars: `\"'&()*,;<=>? []{|}";
if(-e "$cygwinpath/bin/rxvt.exe"){
if(-e "$cygwinpath/bin/unzip.exe"){
}
}else{
print RED "File $cygwinpath/bin/rxvt.exe or $cygwinpath/bin/unzip.exe is
missing,\nreinstall cygwin.\n"; print WHITE"";
goto ENDFILE;
}
@check;
system($mkdir);
system($startcygwin1); #Start Cygwin.
#CYGWINBAT
$movecygwinbat = "$cygwinpath/bin/mv.exe $cygwinpath/cygwin.bat $cygwin
path/tmp/$installbackup/$date_time/cygwin.bat";
OpenFile("cygwin.bat","$movecygwinbat","$cygwinbat","tmp");
system($permissions); #Change permissions.

push(@check, Checkfile("$cygwinpath/cygwin.bat"));
#PROFILE
$moveprofile
= "$cygwinpath/bin/mv.exe $cygwinpath/etc/profile $cygwi
npath/tmp/$installbackup/$date_time/profile";
OpenFile("/etc/profile","$moveprofile","$profile");
push(@check, Checkfile("$cygwinpath/etc/profile"));
`set USER=$user
set HOME=/home/$user
set SHELL=/bin/bash`;
system($startcygwin2); #Start Cygwin.
#BASHRC
if(-e "$cygwinpath/home/$user/.bashrc"){
$movebashrc
= "$cygwinpath/bin/mv.exe $cygwinpath/home/$user
/.bashrc $cygwinpath/tmp/$installbackup/$date_time/.bashrc";
}
OpenFile("/home/$user/.bashrc","$movebashrc","$bashrc");
push(@check, Checkfile("$cygwinpath/home/$user/.bashrc"));
#INPUTRC
if(-e "$cygwinpath/home/$user/.inputrc"){
$moveinputrc
= "$cygwinpath/bin/mv.exe $cygwinpath/home/$user
/.inputrc $cygwinpath/tmp/$installbackup/$date_time/.inputrc";
}
OpenFile("/home/$user/.inputrc","$moveinputrc","$inputrc");
push(@check, Checkfile("$cygwinpath/home/$user/.inputrc"));
#XDEFAULTS
if(-e "$cygwinpath/home/$user/.Xdefaults"){
$movexdefaults = "$cygwinpath/bin/mv.exe $cygwinpath/home/$user
/.Xdefaults $cygwinpath/tmp/$installbackup/$date_time/.Xdefaults";
}
OpenFile("/home/$user/.Xdefaults","$movexdefaults","$xdefaults");
push(@check, Checkfile("$cygwinpath/home/$user/.Xdefaults"));
if(@check != null){
print RED"FAILED, FILES IS MISSING\n";
print @check; print WHITE"";
goto ENDFILE;
}else{
print GREEN"Patching of files seems to be ok!\n"; print WHITE"";
}
sub OpenFile(){
my ($file,$move,$var) =@_;
system($move);
open(NEWFILE, ">$cygwinpath/$file");
print NEWFILE "$var";
close(NEWFILE);
}
sub Checkfile(){
my ($file) = @_;
#print "$file\n";
if(-e "$file"){
}
else{
return "$file\n";
}
}

ENDFILE:
exit;

S-ar putea să vă placă și