all:
	cat REQUIREMENTS

install: all
	# /usr/local/bin files
	cp bin/adduser bin/touch_em /usr/local/bin
	chown root.root /usr/local/bin/adduser /usr/local/bin/touch_em
	chown 740 /usr/local/bin/adduser /usr/local/bin/touch_em

	# /etc
	cp /etc/exports /etc/exports.before_anonymous
	cat etc/exports >> /etc/exports
	cp /etc/crontab /etc/crontab.before_anonymous
	cat etc/crontab >> /etc/crontab
	kill -HUP `pidof cron`

	# /
	cp root/.profile root/.login /
	chown root.root /.profile /.login
	chmod 644 /.profile /.login

	# /etc/skel
	cp skel/.bash_logout skel/.logout /etc/skel
	chown root.root /etc/skel/.bash_logout /etc/skel/.logout
	chmod 644 /etc/skel/.bash_logout /etc/skel/.logout
	mkdir -m 700 /etc/skel/tmp

	# /sbin/init.d
	cp /sbin/init.d/boot.local /sbin/init.d/boot.local.before_anonymous
	cp init.d/boot.local init.d/cleanup init.d/privacy /sbin/init.d
	chown root.root /sbin/init.d/boot.local /sbin/init.d/privacy /sbin/init.d/cleanup
	chmod 700 /sbin/init.d/boot.local /sbin/init.d/privacy /sbin/init.d/cleanup

	# symlinks
	cd /sbin/init.d/rc2.d && ( \
	ln -s ../privacy S40privacy; \
	ln -s ../privacy K05privacy; \
	ln -s ../cleanup K39cleanup; )
	cd / && ( \
	ln -s /dev/null .bash_history; \
	ln -s /dev/null .history; \
	ln -s /dev/null .sh_history; )

	# end
	@echo
	@echo Done.
	@echo Typ \"make setup\" now to create /crypt directories etc.

setup:
	if [ ! -d /crypt ]; then mkdir -m 711 /crypt; fi
	@echo Generating new /etc/fstab
	install/make_fstab
	@echo Setting up new /var/log and /var/run
	install/make_logs
	@echo Moving /var/tmp, /usr/tmp and /usr/local/tmp to /tmp
	install/make_tmpdirs

	# end
	@echo
	@echo Done.
	@echo Type \"make convert\" to convert all /home directories to CFS now.

convert:
	install/addprivacytoallusers
	@echo
	@echo Everything is done now. Type "reboot".
