Sie sind auf Seite 1von 4

#--------------------------------------------------------------------------------------------# Installation of cygwin64.

# 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;
$cygwin64path = "c:/cygwin64";
$startcygwin641 = "$cygwin64path/bin/bash.exe -c \"echo opening and closing cygw
in64...done.\"";
$startcygwin642 = "$cygwin64path/bin/rxvt.exe -sl 65000 -e /bin/bash --login -i
\"echo opening and closing cygwin64...done.\"";
#$signum = $ENV{'USERNAME'};
$signum = `$cygwin64path/bin/whoami`; chomp($signum);
$permissions
= "$cygwin64path/bin/chmod 755 $cygwin64path/cygwin64.bat";
$installbackup = "installbackup";
$date_time = "$year-$mon-$mday\_$hour.$min";
$mkdir = "$cygwin64path/bin/mkdir.exe -p $cygwin64path/tmp/$installbackup/$date_
time";
#cygwin64.BAT
$cygwin64bat ="\@echo off\n
C:
chdir C:\\cygwin64\\bin\n
set USER=$signum
set HOME=/home/$signum
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=$signum
export HOME=/home/$signum
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/$signum/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: White
Rxvt*saveLines: 65535
Rxvt*termName: xterm
Rxvt*geometry: 144x64+0+0
Rxvt*loginShell: true
Rxvt*font: \"Lucida Console-11\"
Rxvt*cutchars: `\"'&()*,;<=>? []{|}";
if(-e "$cygwin64path/bin/rxvt.exe"){
if(-e "$cygwin64path/bin/unzip.exe"){
}
}else{
print RED "File $cygwin64path/bin/rxvt.exe or $cygwin64path/bin/unzip.ex
e is missing,\nreinstall cygwin64.\n"; print WHITE"";
goto ENDFILE;
}
@check;
system($mkdir);
system($startcygwin641); #Start cygwin64.
#cygwin64BAT
$movecygwin64bat
= "$cygwin64path/bin/mv.exe $cygwin64path/cygwin
64.bat $cygwin64path/tmp/$installbackup/$date_time/cygwin64.bat";
OpenFile("cygwin64.bat","$movecygwin64bat","$cygwin64bat","tmp");
system($permissions); #Change permissions.

push(@check, Checkfile("$cygwin64path/cygwin64.bat"));
#PROFILE
$moveprofile
= "$cygwin64path/bin/mv.exe $cygwin64path/etc/profile $c
ygwin64path/tmp/$installbackup/$date_time/profile";
OpenFile("/etc/profile","$moveprofile","$profile");
push(@check, Checkfile("$cygwin64path/etc/profile"));
`set USER=$signum
set HOME=/home/$signum
set SHELL=/bin/bash`;
system($startcygwin642); #Start cygwin64.
#BASHRC
if(-e "$cygwin64path/home/$signum/.bashrc"){
$movebashrc
= "$cygwin64path/bin/mv.exe $cygwin64path/home/$
signum/.bashrc $cygwin64path/tmp/$installbackup/$date_time/.bashrc";
}
OpenFile("/home/$signum/.bashrc","$movebashrc","$bashrc");
push(@check, Checkfile("$cygwin64path/home/$signum/.bashrc"));
#INPUTRC
if(-e "$cygwin64path/home/$signum/.inputrc"){
$moveinputrc
= "$cygwin64path/bin/mv.exe $cygwin64path/home/$
signum/.inputrc $cygwin64path/tmp/$installbackup/$date_time/.inputrc";
}
OpenFile("/home/$signum/.inputrc","$moveinputrc","$inputrc");
push(@check, Checkfile("$cygwin64path/home/$signum/.inputrc"));
#XDEFAULTS
if(-e "$cygwin64path/home/$signum/.Xdefaults"){
$movexdefaults = "$cygwin64path/bin/mv.exe $cygwin64path/home/$
signum/.Xdefaults $cygwin64path/tmp/$installbackup/$date_time/.Xdefaults";
}
OpenFile("/home/$signum/.Xdefaults","$movexdefaults","$xdefaults");
push(@check, Checkfile("$cygwin64path/home/$signum/.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, ">$cygwin64path/$file");
print NEWFILE "$var";
close(NEWFILE);
}
sub Checkfile(){
my ($file) = @_;
#print "$file\n";
if(-e "$file"){
}
else{
return "$file\n";
}
}

ENDFILE:
exit;

Das könnte Ihnen auch gefallen