| verzia 1.1, 2003/05/28 23:52:55 |
verzia 1.2, 2003/07/01 22:19:36 |
|
|
| # Changelog: |
# Changelog: |
| # 16/03/2003 - created |
# 16/03/2003 - created |
| # 20/03/2003 - do not copy /dev/ if already exists |
# 20/03/2003 - do not copy /dev/ if already exists |
| |
# 01/07/2003 - configurable $TFTPBOOT_ROOT and $TFTPBOOT_FIXED variables |
| # |
# |
| |
|
| # $Platon: $ |
# $Platon: scripts/shell/sysadmin/diskless-makeroot.sh,v 1.1 2003/05/28 23:52:55 nepto Exp $ |
| |
|
| |
TFTPBOOT_ROOT="/var/tftpboot/"; |
| |
TFTPBOOT_FIXED="/etc/tftpboot/"; |
| |
|
| # |
# |
| # Input parameter check |
# Input parameter check |
|
|
| # |
# |
| |
|
| print_message 'Creating root directory.'; |
print_message 'Creating root directory.'; |
| echo " /tftpboot/$ip"; |
echo " $TFTPBOOT_ROOT/$ip"; |
| mkdir -p "/tftpboot/$ip" || exit; |
mkdir -p "$TFTPBOOT_ROOT/$ip" || exit; |
| |
|
| # |
# |
| # Basic subdirectories |
# Basic subdirectories |
| Riadok 64 mkdir -p "/tftpboot/$ip" || exit; |
|
| Riadok 68 mkdir -p "/tftpboot/$ip" || exit; |
|
| |
|
| print_message 'Creating basic subdirectories.'; |
print_message 'Creating basic subdirectories.'; |
| for d in home mnt proc usr opt var var/tmp; do |
for d in home mnt proc usr opt var var/tmp; do |
| echo " /tftpboot/$ip/$d"; |
echo " $TFTPBOOT_ROOT/$ip/$d"; |
| mkdir -p "/tftpboot/$ip/$d" || exit; |
mkdir -p "$TFTPBOOT_ROOT/$ip/$d" || exit; |
| done |
done |
| |
|
| # |
# |
|
|
| # |
# |
| |
|
| print_message 'Preserving directory structure of /mnt/ directory.'; |
print_message 'Preserving directory structure of /mnt/ directory.'; |
| find /mnt/ -maxdepth 1 -type d | sed "s,^/,/tftpboot/$ip/,g" | xargs mkdir -p |
find /mnt/ -maxdepth 1 -type d | sed "s,^/,$TFTPBOOT_ROOT/$ip/,g" | xargs mkdir -p |
| print_message 'Preserving directory structure of /var/ directory.'; |
print_message 'Preserving directory structure of /var/ directory.'; |
| find /var/ -maxdepth 4 -type d | sed "s,^/,/tftpboot/$ip/,g" | xargs mkdir -p |
find /var/ -maxdepth 4 -type d | sed "s,^/,$TFTPBOOT_ROOT/$ip/,g" | xargs mkdir -p |
| |
|
| # |
# |
| # Symbolic links |
# Symbolic links |
| # |
# |
| |
|
| print_message "Creating symbolic links."; |
print_message "Creating symbolic links."; |
| echo " /tftpboot/$ip/tmp -> /tftpboot/$ip/var/tmp"; |
echo " $TFTPBOOT_ROOT/$ip/tmp -> $TFTPBOOT_ROOT/$ip/var/tmp"; |
| if [ ! -e "/tftpboot/$ip/tmp" ]; then |
if [ ! -e "$TFTPBOOT_ROOT/$ip/tmp" ]; then |
| ln -s "/var/tmp" "/tftpboot/$ip/tmp" || exit; |
ln -s "/var/tmp" "$TFTPBOOT_ROOT/$ip/tmp" || exit; |
| fi |
fi |
| echo " /tftpboot/$ip/var/mail -> /tftpboot/$ip/var/spool/mail"; |
echo " $TFTPBOOT_ROOT/$ip/var/mail -> $TFTPBOOT_ROOT/$ip/var/spool/mail"; |
| if [ ! -e "/tftpboot/$ip/var/mail" ]; then |
if [ ! -e "$TFTPBOOT_ROOT/$ip/var/mail" ]; then |
| ln -s "/var/spool/mail" "/tftpboot/$ip/var/mail" || exit; |
ln -s "/var/spool/mail" "$TFTPBOOT_ROOT/$ip/var/mail" || exit; |
| fi |
fi |
| |
|
| # |
# |
|
|
| |
|
| print_message 'Copying core directories.'; |
print_message 'Copying core directories.'; |
| for d in bin lib sbin dev etc root; do |
for d in bin lib sbin dev etc root; do |
| echo -n " /tftpboot/$ip/$d"; |
echo -n " $TFTPBOOT_ROOT/$ip/$d"; |
| if [ "$d" = dev ]; then |
if [ "$d" = dev ]; then |
| if [ -d "/tftpboot/$ip/$d" ]; then |
if [ -d "$TFTPBOOT_ROOT/$ip/$d" ]; then |
| echo ": already exists, skipping"; |
echo ": already exists, skipping"; |
| continue; |
continue; |
| fi |
fi |
| fi |
fi |
| echo ""; |
echo ""; |
| mkdir -p "/tftpboot/$ip/$d" || exit; |
mkdir -p "$TFTPBOOT_ROOT/$ip/$d" || exit; |
| cp -f -a $d "/tftpboot/$ip/"; |
cp -f -a $d "$TFTPBOOT_ROOT/$ip/"; |
| done |
done |
| |
|
| # |
# |
|
|
| # |
# |
| |
|
| print_message 'Removing some directories.'; |
print_message 'Removing some directories.'; |
| echo " /tftpboot/$ip/etc/my-rc.d/"; |
echo " $TFTPBOOT_ROOT/$ip/etc/my-rc.d/"; |
| rm -r -f "/tftpboot/$ip/etc/my-rc.d/"; |
rm -r -f "$TFTPBOOT_ROOT/$ip/etc/my-rc.d/"; |
| echo " /tftpboot/$ip/etc/my-ppp/"; |
echo " $TFTPBOOT_ROOT/$ip/etc/my-ppp/"; |
| rm -r -f "/tftpboot/$ip/etc/my-ppp/"; |
rm -r -f "$TFTPBOOT_ROOT/$ip/etc/my-ppp/"; |
| |
|
| # |
# |
| # Removing services starting. |
# Removing services starting. |
| Riadok 129 rm -r -f "/tftpboot/$ip/etc/my-ppp/"; |
|
| Riadok 133 rm -r -f "/tftpboot/$ip/etc/my-ppp/"; |
|
| |
|
| print_message 'Removing services starting.'; |
print_message 'Removing services starting.'; |
| for service in kudzu mserver mysql msql wwwoffled smb httpd dhcpd iptables xinetd routed postfix xfs nfs nfslock; do |
for service in kudzu mserver mysql msql wwwoffled smb httpd dhcpd iptables xinetd routed postfix xfs nfs nfslock; do |
| echo " /tftpboot/$ip/etc/rc.d/init.d/$service"; |
echo " $TFTPBOOT_ROOT/$ip/etc/rc.d/init.d/$service"; |
| rm -f "/tftpboot/$ip/etc/rc.d/init.d/$service" || exit; |
rm -f "$TFTPBOOT_ROOT/$ip/etc/rc.d/init.d/$service" || exit; |
| done |
done |
| |
|
| # |
# |
|
|
| # |
# |
| |
|
| print_message 'Overwritting with fixed files.'; |
print_message 'Overwritting with fixed files.'; |
| for src_file in `find "/tftpboot/$ip-fixed/" -type f -o -type d`; do |
for src_file in `find "$TFTPBOOT_FIXED/$ip/" -type f -o -type d`; do |
| dest_file=`echo "$src_file" | sed "s,^/tftpboot/$ip-fixed,/tftpboot/$ip,g"`; if [ "$src_file" = "$dest_file" ]; then |
dest_file=`echo "$src_file" | sed "s,^$TFTPBOOT_FIXED/$ip,$TFTPBOOT_ROOT/$ip,g"`; |
| |
if [ "$src_file" = "$dest_file" ]; then |
| exit; |
exit; |
| fi |
fi |
| if [ -d "$src_file" ]; then |
if [ -d "$src_file" ]; then |
|
|
| # |
# |
| |
|
| print_message "Creating fast booting undeletable file."; |
print_message "Creating fast booting undeletable file."; |
| echo " /tftpboot/$ip/fastboot"; |
echo " $TFTPBOOT_ROOT/$ip/fastboot"; |
| touch "/tftpboot/$ip/fastboot" || exit; |
touch "$TFTPBOOT_ROOT/$ip/fastboot" || exit; |
| #chattr +i "/tftpboot/$ip/fastboot" || exit; |
#chattr +i "$TFTPBOOT_ROOT/$ip/fastboot" || exit; |
| |
|
| # |
# |
| # Other fixes |
# Other fixes |
| # |
# |
| |
|
| chown -R gdm.gdm "/tftpboot/$ip/var/lib/gdm"; |
chown -R gdm.gdm "$TFTPBOOT_ROOT/$ip/var/lib/gdm"; |
| chmod -R 0750 "/tftpboot/$ip/var/lib/gdm"; |
chmod -R 0750 "$TFTPBOOT_ROOT/$ip/var/lib/gdm"; |
| chmod -R 1777 "/tftpboot/$ip/var/tmp"; |
chmod -R 1777 "$TFTPBOOT_ROOT/$ip/var/tmp"; |
| chmod -R 1777 "/tftpboot/$ip/var/lib/texmf"; |
chmod -R 1777 "$TFTPBOOT_ROOT/$ip/var/lib/texmf"; |
| chmod --reference=/var/spool/mail "/tftpboot/$ip/var/spool/mail"; |
chmod --reference=/var/spool/mail "$TFTPBOOT_ROOT/$ip/var/spool/mail"; |
| |
|