install script

hey all, I just wanted to see if there was anyone that would help me make my poorly written script into a decent install script.

My purpose is to try and create a somewhat automated script that will chmod sensitive files, append data and configure files, install and build packages and update / make world all in 1 go.

my goal is to automate a complete custom install and config, but before I go much further I would like to learn how to make my script look better and perform the tasks at hand. I'm somewhat new to bsd / scripting.

Thanks.

Code:
# clean up install files

mv /var/tmp/* /tmp/
rm -rf /var/tmp
ln -s /tmp /var/tmp

# change system to blowfish passwords & set up password restrictions

echo "crypt_default = blf" >> /etc/auth.conf
echo ":minpasswordlen=8:\" >> /etc/login.conf
echo ":mixasswordcase=true:\" >> /etc/login.conf
echo ":passwordtime=90d:\" >> /etc/login.conf
echo ":idletime=30:\" >> /etc/loging.conf

cap_mkdb /etc/login.conf

# set up ssh logins

echo "#  PermitRootLogin=no" >> /etc/ssh/ssh_config
echo "#  AllowGroups wheel sshlogins" >> /etc/ssh/ssh_config 
echo "#  Protocol 2" >> /etc/ssh/ssh_config
echo "#  X11Forwarding=no" >> /etc/ssh/ssh_config
echo "#  VersionAddendum" >> /etc/ssh/ssh_config

# set up cron job access

echo "root" > /var/cron/allow
echo "root" > /var/at/at.allow
chmod o= /etc/crontab
chmod o= /usr/bin/at
chmod o= /usr/bin/atq
chmod o= /usr/atrm
chmod o= /usr/bin/batch

# set access to config files

chmod o= /etc/fstab
chmod o= /etc/ftpusers
chmod o= /etc/group
chmod o= /etc/hosts
chmod o= /etc/hosts.allow
chmod o= /etc/hosts.equiv
chmod o= /etc/hosts.lpd
chmod o= /etc/inetd.conf
chmod o= /etc/login.access
chmod o= /etc/login.conf
chmod o= /etc/newsyslog.conf
chmod o= /etc/rc.conf
chmod o= /etc/ssh/sshd_config
chmod o= /etc/sysctl.conf
chmod o= /etc/syslog.conf
chmod o= /etc/ttys

# protect logfiles

echo chmod o= /var/log
echo chflags sappnd /var/log
echo chflags sappnd /var/log/*

# remove access from commands

chmod o= /usr/bin/users
chmod o= /usr/bin/w
chmod o= /usr/bin/who
chmod o= /usr/bin/lastcomm
chmod o= /usr/sbin/jls
chmod o= /usr/bin/last
chmod o= /usr/sbin/lastlogin

# Auto compile and install software

portsnap fetch extract

cd /usr/ports/x11-wm/fluxbox/ %% make install distclean
cd /usr/ports/multimedia/xmms/ && make install clean
cd /usr/ports/x11-wm/nautilus/ && make install clean
cd /usr/ports/graphics/gimp/ && make install clean
cd /usr/ports/editors/bluefish/ && make install clean
cd /usr/ports/x11/aterm/ && make install clean
cd /usr/ports/irc/xchat/ && make install clean
cd /usr/ports/print/acroread8/ && make install clean
cd /usr/ports/editors/vim/ && make install clean
cd /usr/ports/ftp/filezilla/ && make install clean
cd /usr/ports/www/opera/ && make install clean
cd /usr/ports/graphics/feh/ && make install clean
cd /usr/ports/editors/emacs/ && make install clean
cd /usr/ports/multimedia/vlc/ && make install clean
cd /usr/ports/editors/abiword/ && make install clean
cd /usr/ports/math/gnumeric/ && make install clean
cd /usr/ports/graphics/scrot/ && make install clean

# set up rc.conf file

echo "dbus_enable="YES"" >> /etc/rc.conf
echo "hald_enable="YES"" >> /etc/rc.conf
echo "gdm_enable="YES"" >> /etc/rc.conf
echo "linux_enable="YES"" >> /etc/rc.conf
echo "hostname="blackstar"" >> /etc.rc.conf
echo "ifconfig_bfe0="DHCP"" >> /etc/rc.conf
echo "keyrate="fast"" >> /etc/rc.conf
echo "rpcbind_enable="YES"" >> /etc/rc.conf
echo "wlans_rum0="wlan0"" >> /etc/rc.conf
echo "ifconfig_wlan0="WPA SYNCDHCP"
echo "defaultrouter="192.168.0.1"" >> /etc/rc.conf

# configure wifi 

cp wpa_supplicant.conf
echo "network={" >> /etc/wpa_supplicant.conf
echo "     ssid="void"" >> /etc/wpa_supplicant.conf
echo "}" >> /etc/wpa_supplicant.conf

# set mixer sound level to 100

echo "hint.pcm.0.vol="100"" >> /etc/boot/device.hints

# to cheat and enable all sound drivers edit /etc/defaults/loader.conf and un comment as nessary

# add devices to fstabs

echo "proc	/proc	procfs	rw	0	0" >> /etc/fstab
echo "linproc	/usr/compat/linux/proc	linprocfs	rw	0	0" >> /etc/fstab

# overide linux f10

echo "OVERRIDE_LINUX_BASE_PORT=f10" >> /etc/make.conf
echo "OVERRIDE_LINUX_NONBASE_PORTS=f10" >> /etc/make.conf

# enable sound and wifi

echo "snd_hda_load="YES"" >> /boot/loader.conf
echo "if_rum_load="YES"" >> /boot/loader.conf

# make world

cd /usr/src/ && make buildworld
 
Code:
cd /usr/ports/x11-wm/fluxbox/ %% make install distclean
cd /usr/ports/multimedia/xmms/ && make install clean
cd /usr/ports/x11-wm/nautilus/ && make install clean
cd /usr/ports/graphics/gimp/ && make install clean
cd /usr/ports/editors/bluefish/ && make install clean
cd /usr/ports/x11/aterm/ && make install clean
cd /usr/ports/irc/xchat/ && make install clean
cd /usr/ports/print/acroread8/ && make install clean
cd /usr/ports/editors/vim/ && make install clean
cd /usr/ports/ftp/filezilla/ && make install clean
cd /usr/ports/www/opera/ && make install clean
cd /usr/ports/graphics/feh/ && make install clean
cd /usr/ports/editors/emacs/ && make install clean
cd /usr/ports/multimedia/vlc/ && make install clean
cd /usr/ports/editors/abiword/ && make install clean
cd /usr/ports/math/gnumeric/ && make install clean
cd /usr/ports/graphics/scrot/ && make install clean
If you want to skip the config menu that comes now and then add BATCH=YES after clean. Also you should add (note this may not be needed if portsnap now does what it should).
Code:
cd /usr/ports/net/cvsup && make install clean BATCH=YES
cp /usr/share/examples/cvsup/ports-supfile ~/ports-supfile
cd ~
chmod u=w ports-supfile
echo "*default host=cvsup.jp.FreeBSD.org" >> ~/ports-supfile #Change the cvsup.jb.FreeBSD.org to your nationality.
csh 
cvsup -L 2 ~/ports-supfile
cd /usr/ports/ports-mgmt/portupgrade && make install clean BATCH=YES
csh
portupgrade -ra BATCH=YES
 
Back
Top