#!/bin/sh # # Short: Create Netscape registry for Mac OS 9 Users # Version: 2.02, 12-09-02 # Author: Mark J Swift, msw AT blackpool.ac.uk # Long: This script will set up an OS 9 netscape registry file for every user # specified by netinfo. It also sets up the users personal toolbar with a # pre-defined list of URLs. The user's bookmarks are untouched. # The script creates the following folders inside the users' folder # "user_name/Library" (u=r/w,g=r/w,o=none) # "user_name/Library/Prefences" (u=r/w,g=r/w,o=none) # "user_name/Library/Prefences/Netscape Ä" (u=r/w,g=r/w,o=none) # The script creates a "Netscape Registry" file for the user # within the "user_name/Library/Prefences" folder: # "user_name/Library/Prefences/Netscape Registry" (u=r/w,g=r/w,o=none) # Finally, the script updates the user's "Bookmarks.html" file - replacing any # URLs in the personal toolbar with a predefined list of URLs (see the listing): # "user_name/Library/Prefences/Netscape Ä/Bookmarks.html" (u=r/w,g=r/w,o=none) # (u=user_name,g=wheel) # # 1. Log in as root # # 2. Copy this script into roots home directory # (/private/var/root/Documents). # # 3. Start a new shell process and change directory to roots home. # # cd ~/Documents # # 4. Set the execute flag is set on the script, type: # # chmod u+x mknetscaperegs.sh # # 5. Execute the "mknetscaperegs.sh" script with the following command: # # ~/Documents/mknetscaperegs.sh # # list of URLs that we want in the users personal toolbar url_addr='https://palmail.blackpool.ac.uk/,http://www.hotmail.com/,http://www.yahoo.com/,http://www.google.com/,http://www.alltheweb.com/' # list of URL descriptions that we want in the users personal toolbar url_desc='College email,MSN Hotmail,Yahoo!,Google,AlltheWeb.com' # SET CONSTANTS fldrchar=`echo "ab" | tr "ab" "\306\222"` pad="................" pad=$pad$pad pad=$pad$pad pad=$pad$pad # -------------------------------- # Set the host id based on the first broadcast interface's IP address # -------------------------------- node_ip=`ifconfig -a | sed -n '/inet/p' | sed -n '/broadcast/p' | head -1 | cut -d' ' -f2` if test -z "$node_ip" then node_ip="127.0.0.1" fi # get the name of this workstation node_name=`uname -n` # -------------------------------- # debug - print host details to screen # -------------------------------- # echo " node_ip:$node_ip" # echo " node_name:$node_name" # -------------------------------- # NetInfo: are we sharing, are we master? # -------------------------------- ni_notshared=`niutil -rparent . | grep -c -y "[.]*no parent"` if [ $ni_notshared -eq 1 ] then ni_isshared=0 ni_ismaster=0 ni_host_name=$node_name else ni_isshared=1 ni_ismaster=`niutil -rparent . | grep -c -y "^$node_name[]*/[]*"` ni_host_name=`niutil -rparent . | cut -d/ -f1 | cut -d. -f1 ` fi if [ $ni_isshared -eq 0 -o $ni_ismaster -eq 1 ] then ni_canmodify=1 else ni_canmodify=0 fi # -------------------------------- # debug - print host NetInfo details to screen # -------------------------------- # echo " ni_is_shared:$ni_isshared" # echo " ni_is_master:$ni_ismaster" # echo " ni_canmodify:$ni_canmodify" # echo " ni_host_name:$ni_host_name" # is the machine defined in NetInfo? count=`nireport / /machines name | grep -c -y "^$ni_host_name"` if [ $count -eq 0 ] then ni_host_ip=$node_ip else ni_host_ip=`niutil -read / /machines/$ni_host_name | grep -y "^ip_address: " | cut -d: -f2 | tr -d "\040"` fi # is IP valid? count=`echo "$ni_host_ip" | grep -c -y "^127.0.0.1\b"` if [ $count -ne 0 ] then ni_host_ip=$node_ip fi # -------------------------------- # debug - print host NetInfo details to screen # -------------------------------- # echo " ni_host_ip:$ni_host_ip" for ni_user_name in `nireport / /users name` do ni_user_id=`niutil -read / /users/$ni_user_name | grep -y "^uid: " | cut -d: -f2 | cut -c2-` if [ $ni_user_id -gt 1024 ] then ni_user_realname=`niutil -read / /users/$ni_user_name | grep -y "^realname: " | cut -d: -f2 | cut -c2-` ni_user_home=`niutil -read / /users/$ni_user_name | grep -y "^home: " | cut -d: -f2 | cut -c2-` ni_user_gid=`niutil -read / /users/$ni_user_name | grep -y "^gid: " | cut -d: -f2 | cut -c2-` # -------------------------------- # debug - print user home details to screen # -------------------------------- # echo " ni_user_name: $ni_user_name" # echo " ni_user_id: $ni_user_id" # echo " ni_user_realname: $ni_user_realname" # echo " ni_user_home: $ni_user_home" # echo " ni_user_gid: $ni_user_gid" ni_user_host=`niutil -read / /users/$ni_user_name | grep -y "^home_loc: " | cut -d: -f3 | cut -d/ -f3 ` ni_user_share_point=`niutil -read / /users/$ni_user_name | grep -y "^home_loc: " | cut -d: -f3 | cut -d/ -f4 | cut -d"<" -f1 ` ni_user_share_fldr=`niutil -read / /users/$ni_user_name | grep -y "^home_loc: " | cut -d"<" -f5 | cut -d">" -f2` # echo " ni_user_host: $ni_user_host" # echo " ni_user_share_point: $ni_user_share_point" # echo " ni_user_share_fldr: $ni_user_share_fldr" # does this server host the users home folder? count=`echo "$ni_user_home" | grep -c -y "^/Network/Servers/$node_name\b"` if [ $count -ne 0 ] then ni_user_path=/`echo $ni_user_home | cut -d/ -f5-` # echo " ni_user_path: $ni_user_path" # does user home exist? if test -d "$ni_user_path" then # yes, folder is there! # does Library folder exist? if test -d "$ni_user_path/Library" then # yes, folder is there! echo " : updating directory $ni_user_path/Library" else echo " : making directory $ni_user_path/Library" mkdir "$ni_user_path/Library" fi chown -R $ni_user_id "$ni_user_path/Library" chgrp -R 0 "$ni_user_path/Library" chmod -R 770 "$ni_user_path/Library" # does Library/Preferences folder exist? if test -d "$ni_user_path/Library/Preferences" then # yes, folder is there! echo " : updating directory $ni_user_path/Library/Preferences" else echo " : making directory $ni_user_path/Library/Preferences" mkdir "$ni_user_path/Library/Preferences" fi chown -R $ni_user_id "$ni_user_path/Library/Preferences" chgrp -R 0 "$ni_user_path/Library/Preferences" chmod -R 770 "$ni_user_path/Library/Preferences" nsf="Netscape $fldrchar" # does "Library/Preferences/Netscape Ä" folder exist? if test -d "$ni_user_path/Library/Preferences/$nsf" then # yes, folder is there! echo " : updating directory $ni_user_path/Library/Preferences/$nsf" else echo " : making directory $ni_user_path/Library/Preferences/$nsf" mkdir "$ni_user_path/Library/Preferences/$nsf" fi book_old_file="$ni_user_path/Library/Preferences/$nsf/Bookmarks.html" book_tmp_file="$ni_user_path/Library/Preferences/$nsf/junk.html" echo >"$book_tmp_file" '' echo >>"$book_tmp_file" '' echo >>"$book_tmp_file" "Bookmarks for $ni_user_realname " echo >>"$book_tmp_file" "

Bookmarks for $ni_user_realname

" echo >>"$book_tmp_file" '

' echo >>"$book_tmp_file" '

Personal Toolbar Folder

' echo >>"$book_tmp_file" '

' reqd_url_addr="$url_addr" reqd_url_desc="$url_desc" while [ "$reqd_url_desc" ]; do # get a url address addr=`echo $reqd_url_addr | cut -d, -f1` reqd_url_addr=`echo "$reqd_url_addr" | cut -d, -s -f2-` # get a url description desc=`echo $reqd_url_desc | cut -d, -f1` reqd_url_desc=`echo "$reqd_url_desc" | cut -d, -s -f2-` echo -n >>"$book_tmp_file" '

>"$book_tmp_file" '" ADD_DATE="1028811746" LAST_VISIT="1028811875" LAST_MODIFIED="1028811875">' echo -n >>"$book_tmp_file" "$desc" echo >>"$book_tmp_file" '' done echo >>"$book_tmp_file" '

' # does bookmarks file exist? if test -f "$book_old_file" then echo " : updating file $book_old_file" # -------------------------------- # read bookmarks from bookmarks file # -------------------------------- flg=0 tr -s "\015" "\012" < "$book_old_file" | while read whole_line do if [ $flg -ne 0 ] then echo >>"$book_tmp_file" "$whole_line" else flg=`echo "$whole_line" | grep -c -y "

"` fi done rm "$book_old_file" else # no bookmarks file echo " : creating file $book_old_file" echo >>"$book_tmp_file" '

' fi mv "$book_tmp_file" "$book_old_file" chown -R $ni_user_id "$ni_user_path/Library/Preferences/$nsf" chgrp -R 0 "$ni_user_path/Library/Preferences/$nsf" chmod -R 770 "$ni_user_path/Library/Preferences/$nsf" netscape_fldr=`echo "$ni_user_share_point/$ni_user_share_fldr/Library/Preferences/$nsf" | tr "/" ":"` netscape_flen=`expr "$netscape_fldr" : '.*'` # -------------------------------- # debug - print details to screen # -------------------------------- # echo " netscape_fldr: $netscape_fldr" # echo " netscape_flen: $netscape_flen" reg_file="$ni_user_path/Library/Preferences/Netscape Registry" # -------------------------------- # create Netscape Registry file # (note: don't understand the registry format, but got # enough info by comparing different registry files) # -------------------------------- echo " : creating file $reg_file" printf >$reg_file 'ADdv\001\0\002\0\300\003\0\0\202\0\0\0' printf >>$reg_file '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' printf >>$reg_file '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' printf >>$reg_file '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' printf >>$reg_file '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' printf >>$reg_file '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' printf >>$reg_file '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' printf >>$reg_file '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' printf >>$reg_file '\057\0\202\0\0\0\200\0\0\0\002\0\001\0\0\0' printf >>$reg_file '\0\0\057\001\0\0\0\0\0\0\0\0\0\0\0\0' printf >>$reg_file '\0\000Users\0\250\0\0\0\242\0\0\0' printf >>$reg_file '\006\0\001\0\0\0\0\0\136\001\0\0\0\0\0\0' printf >>$reg_file '\0\0\0\0\202\0\0\000Common\0\317' printf >>$reg_file '\0\0\0\310\0\0\0\007\0\001\0\250\0\0\0\361' printf >>$reg_file '\001\0\0\0\0\0\0\0\0\0\0\202\0\0\000V' printf >>$reg_file 'ersion Registry\0' printf >>$reg_file '\0\001\0\0\357\0\0\0\021\0\001\0\317\0\0\0' printf >>$reg_file '\0\0\0\0\0\0\0\0\0\0\0\0\202\0\0\0' printf >>$reg_file 'Private Arenas\0\057' printf >>$reg_file '\001\0\0\040\001\0\0\017\0\001\0\0\001\0\0\211' printf >>$reg_file '\002\0\0\0\0\0\0\0\0\0\0\202\0\0\000d' printf >>$reg_file 'efault\04520user\0\136\001' printf >>$reg_file '\0\0\117\001\0\0\017\0\001\0\0\0\0\0\0\0' printf >>$reg_file '\0\0\310\001\0\0\0\0\0\0\250\0\0\000Pr' printf >>$reg_file 'ofileLocation\000SY' printf >>$reg_file 'S:System Folder:' printf >>$reg_file 'Preferences:Nets' printf >>$reg_file 'cape Users:defau' printf >>$reg_file 'lt user\0\310\001\0\0\176\001\0\0' printf >>$reg_file '\020\0\021\0\0\0\0\0\200\0\0\0\100\003\0\0' o=`expr $netscape_flen + 1` o0=`expr $o % 8` o=`expr $o / 8` o1=`expr $o % 8` o=`expr $o / 8` o2=`expr $o % 8` printf >>$reg_file \\$o2$o1$o0 printf >>$reg_file '\0\0\0\136\001\0\000Netscape' printf >>$reg_file '\0\361\001\0\0\350\001\0\0\011\0\001\0\0\0\0' printf >>$reg_file '\0\040\002\0\0\0\0\0\0\0\0\0\0\317\0\0' printf >>$reg_file '\000ProfileManager\0' printf >>$reg_file '\040\002\0\0\021\002\0\0\017\0\001\0\0\0\0\0' printf >>$reg_file '\0\0\0\0\140\002\0\0\0\0\0\0\361\001\0\0' printf >>$reg_file 'LastNetscapeUser' printf >>$reg_file '\000default\04520user\0' printf >>$reg_file '\140\002\0\0\100\002\0\0\021\0\021\0\0\0\0\0' printf >>$reg_file '\017\0\0\0\121\002\0\0\017\0\0\0\040\002\0\0' printf >>$reg_file 'Netscape\0\211\002\0\0\200\002\0' printf >>$reg_file '\0\011\0\001\0\0\0\0\0\266\002\0\0\0\0\0' printf >>$reg_file '\0\0\0\0\0\057\001\0\000Communi' printf >>$reg_file 'cator\0\266\002\0\0\251\002\0\0\015\0' printf >>$reg_file '\001\0\0\0\0\0\345\002\0\0\0\0\0\0\0\0' printf >>$reg_file '\0\0\211\002\0\000SoftwareUp' printf >>$reg_file 'date\0\345\002\0\0\326\002\0\0\017\0\001' printf >>$reg_file '\0\0\0\0\0\0\0\0\0\040\003\0\0\0\0\0' printf >>$reg_file '\0\266\002\0\000LastRegPack' printf >>$reg_file 'Time\0001027961421\0' printf >>$reg_file '\040\003\0\0\005\003\0\0\020\0\021\0\0\0\0\0' printf >>$reg_file '\013\0\0\0\025\003\0\0\013\0\0\0\345\002\0\0' printf >>$reg_file "$netscape_fldr" printf >>$reg_file '\0' o=`expr $netscape_flen + 2` printf >>$reg_file `echo "$pad" | cut -c $o-` chown $ni_user_id "$reg_file" chgrp 0 "$reg_file" chmod 770 "$reg_file" fi fi fi done