#!/usr/bin/perl

# The LearningOnline Network with CAPA
# setup_rpm_binaryroot.pl - script to generate files to make LON-CAPA-setup rpm
#
# $Id: setup_rpm_binaryroot.pl,v 1.2 2002/01/09 23:14:22 harris41 Exp $
#
# Written by Scott Harrison, harris41@msu.edu
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA 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.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# http://www.lon-capa.org/
#
# YEAR=2002
# 1/9 - Scott Harrison
#
###

`install -d SetupBinaryRoot`;
`install -d SetupBinaryRoot/etc`;

# /etc/passwd

open OUT,">SetupBinaryRoot/etc/passwd";
print OUT<<END;
root::0:0:root:/root:/bin/bash
bin:!!:1:1:bin:/bin:
daemon:!!:2:2:daemon:/sbin:
adm:!!:3:4:adm:/var/adm:
lp:!!:4:7:lp:/var/spool/lpd:
sync:!!:5:0:sync:/sbin:/bin/sync
shutdown:!!:6:0:shutdown:/sbin:/sbin/shutdown
halt:!!:7:0:halt:/sbin:/sbin/halt
mail:!!:8:12:mail:/var/spool/mail:
news:!!:9:13:news:/var/spool/news:
uucp:!!:10:14:uucp:/var/spool/uucp:
operator:!!:11:0:operator:/root:
games:!!:12:100:games:/usr/games:
gopher:!!:13:30:gopher:/usr/lib/gopher-data:
ftp:!!:14:50:FTP User:/home/ftp:
nobody:!!:99:99:Nobody:/:
www:!!:500:500:www:/home/www:/bin/bash
END
close OUT;

# /etc/group

open OUT,">SetupBinaryRoot/etc/group";
print OUT<<END;
root::0:root
bin::1:root,bin,daemon
daemon::2:root,bin,daemon
sys::3:root,bin,adm
adm::4:root,adm,daemon
tty::5:
disk::6:root
lp::7:daemon,lp
mem::8:
kmem::9:
wheel::10:root
mail::12:mail
news::13:news
uucp::14:uucp
man::15:
games::20:
gopher::30:
dip::40:
ftp::50:
nobody::99:
users::100:
www::500:
END
close OUT;

# /etc/hosts.deny

open OUT,">SetupBinaryRoot/etc/hosts.deny";
print OUT<<END;
ALL: ALL
END
close OUT;
    
# /home/www

`install -o www -g users -m 0700 -d SetupBinaryRoot/home/www`;

# /etc/pam.d

`install -d SetupBinaryRoot/etc/pam.d`;

# /etc/pam.d/passwd

open OUT,">SetupBinaryRoot/etc/pam.d/passwd";
print OUT<<END;
#%PAM-1.0
auth       required     /lib/security/pam_pwdb.so shadow nullok
account    required     /lib/security/pam_pwdb.so
password   required     /lib/security/pam_cracklib.so retry=3
password   required     /lib/security/pam_pwdb.so use_authtok nullok
END
close OUT;

# /etc/pam.d/login

open OUT,">SetupBinaryRoot/etc/pam.d/login";
print OUT<<END;
#%PAM-1.0
auth       required     /lib/security/pam_securetty.so
auth       required     /lib/security/pam_pwdb.so shadow nullok
auth       required     /lib/security/pam_nologin.so
account    required     /lib/security/pam_pwdb.so
password   required     /lib/security/pam_cracklib.so
password   required     /lib/security/pam_pwdb.so nullok use_authtok
session    required     /lib/security/pam_pwdb.so
session    optional     /lib/security/pam_console.so
END
close OUT;
