goto-fai-backend/0000755000175000017500000000000011376007747013506 5ustar benoitbenoitgoto-fai-backend/hooks/0000755000175000017500000000000011353210552014612 5ustar benoitbenoitgoto-fai-backend/hooks/goto-fai-backend0000755000175000017500000000634311375014655017652 0ustar benoitbenoit#!/bin/sh msg() { echo "nfsroot-hooks/gosa: $1" } # Make sysconfig a real directory if [ ! -d "${NFSROOT}"/etc/sysconfig ]; then msg "creating sysconfig directory" mkdir -p "${NFSROOT}"/etc/sysconfig fi # Copy some templates for file in /etc/initramfs-tools/initramfs.conf /etc/initramfs-tools/update-initramfs.conf /etc/usplash.conf; do name=${file##*/} msg "copying $name" [ -f "/etc/fai/nfsroot-templates/$name" ] && cp /etc/fai/nfsroot-templates/$name "${NFSROOT}"$file done # Copy make-fai-nfsroot.conf to allow debootstrapping later on cp /etc/fai/make-fai-nfsroot.conf "${NFSROOT}"/etc/fai #creating pid and socket directory for gosa-si msg "Creating /var/run/gosa-si directory" mkdir -p "${NFSROOT}"/var/run/gosa-si msg "checking if gosa-si server needs to be specified" SERVER="" PARENT="" if [ -f /etc/gosa-si/server.conf ]; then PARENT=$(sed -n '/^\[server\]/,/^$/{s/^ip = \(.*\)$/\1/p}' /etc/gosa-si/server.conf) if [ "$PARENT" = "" ]; then SERVER="ip = $(hostname -f)" fi msg "extracting parents gosa-si credentials" CRED=$(sed -n '/^\[ClientPackages\]/,/^$/{s/^key = \(.*\)$/\1/p}' /etc/gosa-si/server.conf) if [ -f /etc/gosa-si/client.conf.in ]; then msg "adapting gosa-si configuration" sed "s/@@SERVER@@/$SERVER/g;s/^key.*$/key = $CRED/g" /etc/gosa-si/client.conf.in > "${NFSROOT}"/etc/gosa-si/client.conf fi # Fix logging path of NFSrooted client to be /tmp/fai/fai.log... msg "fixing fai-logpath to point to nfsroot location" sed -i 's%^fai-logpath = .*$%fai-logpath = /tmp/fai/fai.log%g' "${NFSROOT}"/etc/gosa-si/client.conf chmod go-rwx "${NFSROOT}"/etc/gosa-si/client.conf # Remove ldap.conf msg "removing ldap configuration" rm "${NFSROOT}"/etc/ldap/ldap.conf else if [ -f /etc/gosa-si/client.conf ]; then msg "Fall back to existing gosa-si client configuration" cp /etc/gosa-si/client.conf "${NFSROOT}"/etc/gosa-si # Fix logging path of NFSrooted client to be /tmp/fai/fai.log... msg "fixing fai-logpath to point to nfsroot location" sed -i 's%^fai-logpath = .*$%fai-logpath = /tmp/fai/fai.log%g' "${NFSROOT}"/etc/gosa-si/client.conf chmod go-rwx "${NFSROOT}"/etc/gosa-si/client.conf else msg "WARNING: there is no gosa-si support in the NFSROOT - installations will fail!" # Copy over original ldap configuration to make things work [ -f /etc/ldap/ldap.conf ] && cp /etc/ldap/ldap.conf "$NFSROOT"/etc/ldap fi fi # Set locale if needed if [ -n "$NFSROOT_LOCALE" ]; then echo "set locales/default_environment_locale $NFSROOT_LOCALE" | chroot $NFSROOT debconf-communicate echo "set locales/locales_to_be_generated $NFSROOT_LOCALE UTF-8" | chroot $NFSROOT debconf-communicate chroot $NFSROOT dpkg-reconfigure -fnoninteractive locales fi # Get newest kernel installed inside the nfsroot version=$(echo $NFSROOT/boot/vmlinuz-* | sort -n | head -n1 | cut -d- -f2-) # Copy as default kernel if [ -f "$NFSROOT/boot/vmlinuz-$version" ]; then msg "installing vmlinuz-install" cp "$NFSROOT/boot/vmlinuz-$version" "$TFTPROOT/vmlinuz-install" else msg "ERROR: cannot find kernel to use as vmlinuz-install!!!" fi # Copy initrd if present if [ -f "$NFSROOT/boot/initrd.img-$version" ]; then msg "installing initrd.img-install" cp "$NFSROOT/boot/initrd.img-$version" "$TFTPROOT/initrd.img-install" fi goto-fai-backend/ldap2repository.10000644000175000017500000001415411376562072016734 0ustar benoitbenoit.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.07) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "LDAP2REPOSITORY 1" .TH LDAP2REPOSITORY 1 "2010-05-19" "perl v5.10.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ldap2repository \- creating debian repositories cronjob for the GOsa FAI plugin. .SH "SYNOPSIS" .IX Header "SYNOPSIS" ldap2repository [\-hvnpej] [\-c config] [\-d outdir] [\-r srvroot] [\-i interface] [\-a arch] [\-P proxy] .SH "DESCRIPTION" .IX Header "DESCRIPTION" ldap2repository is a script to create the cronjob for the local. debian repositories needed by GOsa \s-1FAI\s0 plugin. .IP "\fB\-c\fR \s-1LDAP\s0 config file (default: /etc/ldap/ldap.conf)" 12 .IX Item "-c LDAP config file (default: /etc/ldap/ldap.conf)" .PD 0 .IP "\fB\-d\fR output dir (default: /etc/gosa/fai)" 12 .IX Item "-d output dir (default: /etc/gosa/fai)" .IP "\fB\-h\fR display this help and exit" 12 .IX Item "-h display this help and exit" .IP "\fB\-n\fR skip cleanup for mirrors" 12 .IX Item "-n skip cleanup for mirrors" .IP "\fB\-p\fR show progress in cronjob" 12 .IX Item "-p show progress in cronjob" .IP "\fB\-v\fR be verbose" 12 .IX Item "-v be verbose" .IP "\fB\-i\fR network interface (default: eth0)" 12 .IX Item "-i network interface (default: eth0)" .IP "\fB\-j\fR create a new /etc/cron.d/goto\-fai\-backend" 12 .IX Item "-j create a new /etc/cron.d/goto-fai-backend" .IP "\fB\-r\fR server root (default: /srv/www)" 12 .IX Item "-r server root (default: /srv/www)" .IP "\fB\-e\fR ignore small errors" 12 .IX Item "-e ignore small errors" .IP "\fB\-a\fR processor architecture (default: i386)" 12 .IX Item "-a processor architecture (default: i386)" .IP "\fB\-P\fR proxy (default: none)" 12 .IX Item "-P proxy (default: none)" .PD .SH "BUGS" .IX Header "BUGS" Please report any bugs, or post any suggestions, to the GOsa mailing list or to .SH "LICENCE AND COPYRIGHT" .IX Header "LICENCE AND COPYRIGHT" This code is part of GOsa () .PP Copyright (C) 2005\-2006 Jan-Marek Glogowski 2007\-2010 The GOsa project .PP This program is distributed in the hope that it will be useful, but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of \&\s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. See the \&\s-1GNU\s0 General Public License for more details. goto-fai-backend/ldap2repository0000755000175000017500000002171011374716153016573 0ustar benoitbenoit#!/usr/bin/perl # $Id$ #********************************************************************* # # (c) 2005,2006 Jan-Marek Glogowski # (c) 2007,2009 The GOsa project #********************************************************************* =head1 NAME ldap2repository - creating debian repositories cronjob for the GOsa FAI plugin. =head1 SYNOPSIS ldap2repository [-hvnpej] [-c config] [-d outdir] [-r srvroot] [-i interface] [-a arch] [-P proxy] =head1 DESCRIPTION ldap2repository is a script to create the cronjob for the local. debian repositories needed by GOsa FAI plugin. =over 12 =item B<-c> LDAP config file (default: /etc/ldap/ldap.conf) =item B<-d> output dir (default: /etc/gosa/fai) =item B<-h> display this help and exit =item B<-n> skip cleanup for mirrors =item B<-p> show progress in cronjob =item B<-v> be verbose =item B<-i> network interface (default: eth0) =item B<-j> create a new /etc/cron.d/goto-fai-backend =item B<-r> server root (default: /srv/www) =item B<-e> ignore small errors =item B<-a> processor architecture (default: i386) =item B<-P> proxy (default: none) =back =head1 BUGS Please report any bugs, or post any suggestions, to the GOsa mailing list or to =head1 LICENCE AND COPYRIGHT This code is part of GOsa (L) Copyright (C) 2005-2006 Jan-Marek Glogowski 2007-2010 The GOsa project This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. =cut use strict; use lib "/usr/lib/goto"; use Switch; use Net::LDAP; use MIME::Base64; use Getopt::Std; use File::Path; use File::Copy; use GOto::Common qw(:ldap :file :array); use vars qw/ %opt /; my $base; my $ldapuris; my $ldapdir = "/etc/ldap/ldap.conf"; my $outdir = "/etc/gosa/fai"; my $crond_dir= "/etc/cron.d"; my $interface = "eth0"; my $verbose = 0; my $newcrond = 0; my $opt_string = 'c:d:i:hnpeja:P:r:v'; my $hostname; my $srvdir = "/srv/www"; my $progress = ""; my $nocleanup = ""; my $small_errors = ""; my $arch = "i386"; my $proxy = ""; getopts( "$opt_string", \%opt ) or usage("Wrong parameters"); usage("ldap2repository - creating debian repositories cronjob for the GOsa FAI plugin.") if $opt{h}; $verbose = $opt{v} ? 1 : 0; $newcrond = $opt{j} ? 1 : 0; $outdir = $opt{d} ? $opt{d} : $outdir; $ldapdir = $opt{c} ? $opt{c} : $ldapdir; $interface = $opt{i} ? $opt{i} : $interface; $nocleanup = $opt{n} ? "--nocleanup" : ""; $srvdir = $opt{r} ? $opt{r} : $srvdir; $progress = $opt{p} ? "--progress" : ""; $arch = $opt{a} ? $opt{a} : $arch; $small_errors = $opt{e} ? "--ignore-small-errors" : ""; $proxy = $opt{P} ? "--proxy=".$opt{P} : ""; # initialize ldap ( $base, $ldapuris ) = goto_ldap_parse_config( $ldapdir ); usage( "Couldn't find LDAP base in config!" ) if( ! defined $base ); usage( "Couldn't find LDAP URI in config!" ) if( ! defined $ldapuris ); my $ldap = Net::LDAP->new( $ldapuris ) or die "$@"; my $mesg = $ldap->bind; my $mac = `LANG=C /sbin/ifconfig $interface | awk '/$interface/{ print \$5 }'`; chomp( $mac ); # create class hooks debconf disk_config package_config scripts files -d "$outdir" or mkpath "$outdir" or warn "WARNING: Can't create subdir $outdir: $!\n"; # Is outdir a directory -d "$outdir" || usage("'$outdir' is not a directory.\n"); generate_sources_list(); $mesg = $ldap->unbind; # take down session exit 0; sub usage { (@_) && print STDERR "\n@_\n\n"; print STDERR << "EOF"; usage: $0 [-hvnpej] [-c config] [-d outdir] [-r srvroot] [-i interface] [-a arch] [-P proxy] -h : this (help) message -c : LDAP config file (default: ${ldapdir}) -d : output dir (default: ${outdir}) -i : network interface (default: ${interface}) -j : create a new cron.d/goto-fai-backend -n : skip cleanup for mirrors -p : show progress in cronjob -r : server root (default ${srvdir}) -v : be verbose on generate -P : proxy (default: ${proxy}) -e : ignore small errors -a : processor architecture (default: ${arch}) EOF exit -1; } sub search_repo_server { my ($cn) = @_; my @attrs = ( 'FAIrepository' ); my ($sresult) = goto_ldap_rsearch( $ldap, $base, '', "(&(objectClass=FAIrepositoryServer)(cn=${cn}))", "one", "ou=servers,ou=systems", \@attrs ); return goto_ldap_is_single_result( $sresult, 1 ); } sub generate_sources_list { my ($mesg,$entry,$par_mesg,$par_entry,@entries); my ($line,@deblines,@modsections,@rdns,%saw,$debline); my $hostname = `hostname -f`; $hostname = $1 if ( $hostname =~ m/([a-z0-9\.\-]+).*/g ); if( $verbose ) { print "Generating sources.list and debmirror cronjob for server\n" . "Host: ${hostname}\n" . "Base: ${base}\n" . "Outdir: ${outdir}\n\n"; } open (SOURCES,">${outdir}/sources.list") || die "Can't create ${outdir}/sources.list: $!\n"; open (CRON, ">${outdir}/update-cronjob") || die "Can't create ${outdir}/update-cronjob: $!\n"; # generate new /etc/cron.d/goto-fai-backend if asked # this option allows to add option neccessary # to the got-fai-backend cron if( $newcrond ) { open (CROND, ">${crond_dir}/goto-fai-backend") || die "Can't create ${crond_dir}/goto-fai-backend: $!\n"; print CROND "PATH=/sbin:/bin:/usr/sbin:/usr/bin\n\n"; print CROND "\@reboot root ldap2repository -n -p -e -i $interface -a $arch $proxy; [ -f /etc/gosa/fai/update-cronjob ] && sh /etc/gosa/fai/update-cronjob\n"; print CROND "\@daily root ldap2repository -n -p -e -i $interface -a $arch $proxy; [ -f /etc/gosa/fai/update-cronjob ] && sh /etc/gosa/fai/update-cronjob\n"; close (CROND); } # Write cron script print CRON "#!/bin/sh\n"; $mesg = $ldap->search( base => "$base", filter => "(&(objectClass=FAIrepositoryServer)(macAddress=${mac}))", attrs => [ 'FAIrepository', 'cn' ] ); $mesg->code && die $mesg->error; @entries = $mesg->entries; die "Server object doesn't contain repositories\n" if( 0 == scalar @entries ); $entry = $entries[0]; my ($newbase) = $entry->dn() =~ m/.*ou=systems,(.*)/; if( "$base" ne "$newbase" ) { print( "Switching base: $newbase\n" ) if( $verbose ); $base = $newbase; } foreach my $repoline ($entry->get_value('FAIrepository')){ my (@items) = split('\|',${repoline}); my $uri = $items[0]; my ($dir) = $uri =~ m%.*://[^/]+/(.*)%; my ($localuri) = $uri =~ s%://[^/]+%://localhost%; my $parent_or_opts = $items[1]; my $dist = $items[2]; my $sections = $items[3]; my (@section_list) = split(',',$items[3]); print SOURCES "deb $uri $dist @section_list\n"; print " +S $dist ($sections) via $uri\n" if( $verbose ); if ("" eq "$parent_or_opts") { print( "No parent for '$repoline'\n" ); next; } if (":" eq substr($parent_or_opts,0,1)) { # No GOsa internal mirror or too complicated: write as additional options print CRON "debmirror --ignore-release-gpg --nosource ${small_errors} -a ${arch} --dist=${dist} --sections=${sections} $proxy " . substr($parent_or_opts,1) . "${proxy} ${srvdir}/${dist}\n"; print " +Cc ${dist} (${sections})\n" if( $verbose ); } else { # Check repository release my (@rdns,$search_base); @rdns = split(',',$base); $par_entry = search_repo_server( "${parent_or_opts}" ); if( 0 == $par_entry ) { print( "Couldn't find parent repo server for '$repoline'\n" ); next; } foreach my $par_repoline ($par_entry->get_value('FAIrepository')){ my (@par_items) = split('\|',${par_repoline}); my ($method,$host,$root); if ($par_items[0] =~ m#([^:]+)://([^/]+)(.*)#) { $method = $1; $host = $2; $root = $3; } my $par_dist = $par_items[2]; my @outline = (); if ("$dist" eq "$par_dist") { my (@par_section_list) = split(',', $items[3]); foreach my $section (@par_section_list) { if (goto_array_find_and_remove( \@section_list, ${section})) { push( @outline, $section ); last if (0 == scalar @section_list); } } if (0 != scalar @{outline}) { print CRON "\ndebmirror ${progress} ${nocleanup} --ignore-release-gpg --nosource ${small_errors} -a ${arch} --dist=${dist} --section=" . join(",", @{outline}) . " --method=${method} --host=${host} --root=${root} $proxy ${srvdir}/${dir}\n"; print " +Cs ${dist} (" . join(",", @{outline}) . ") from ${host}\n" if( $verbose ); } last if (0 == scalar @section_list); } } } } close (SOURCES); close (CRON); } # vim:ts=2:sw=2:expandtab:shiftwidth=2:syntax:paste goto-fai-backend/templates/0000755000175000017500000000000011353210553015466 5ustar benoitbenoitgoto-fai-backend/templates/update-initramfs.conf0000644000175000017500000000057411353210553021617 0ustar benoitbenoit# # Configuration file for update-initramfs(8) # # # update_initramfs [ yes | all | no ] # # Default is yes # If set to all update-initramfs will update all initramfs # If set to no disables any update to initramfs beside kernel upgrade update_initramfs=yes # # backup_initramfs [ yes | no ] # # Default is yes # If set to no leaves no .bak backup files. backup_initramfs=no goto-fai-backend/templates/usplash.conf0000644000175000017500000000006011353210553020010 0ustar benoitbenoit# Usplash configuration file xres=1024 yres=768 goto-fai-backend/templates/initramfs.conf0000644000175000017500000000163011353210553020331 0ustar benoitbenoit# # initramfs.conf # Configuration file for mkinitramfs(8). See initramfs.conf(5). # # # MODULES: [ most | netboot | dep | list ] # # most - Add all framebuffer, acpi, filesystem, and harddrive drivers. # # dep - Try and guess which modules to load. # # netboot - Add the base modules, network modules, but skip block devices. # # list - Only include modules from the 'additional modules' list # MODULES=most # # BUSYBOX: [ y | n ] # # Use busybox if available. # BUSYBOX=y # # KEYMAP: [ y | n ] # # Load a keymap during the initramfs stage. # KEYMAP=y # # NFS Section of the config. # # # BOOT: [ local | nfs ] # # local - Boot off of local media (harddrive, USB stick). # # nfs - Boot using an NFS drive as the root of the drive. # # live - Boot using live-initramfs # BOOT=live # # DEVICE: ... # # Specify the network interface, like eth0 # DEVICE=eth0 # # NFSROOT: [ auto | HOST:MOUNT ] # NFSROOT=auto