# Makefile for installing user space scripts

# Programs:
INSTALLER = $(shell which install)

# Directories:
HOTPLUGDIR=/etc/hotplug
INSTALLDIR=/usr/sbin
PPPDIR=/etc/ppp

all:

userscripts:
	./makescripts

install: userscripts
	mkdir -p $(HOTPLUGDIR)/usb
	@if [ -f pap-secrets ]; then \
		$(INSTALLER) -c -m 0600 -o root -g root pap-secrets $(PPPDIR) ; \
	fi
	@if [ -f chap-secrets ]; then \
		$(INSTALLER) -c -m 0600 -o root -g root chap-secrets $(PPPDIR) ; \
	fi
	@if [ -f options.adsl ]; then \
		$(INSTALLER) -c -m 0644 -o root -g root options.adsl $(PPPDIR) ; \
	fi
	$(INSTALLER) -c -m 0554 -o root -g root hotplug/adiusb* $(HOTPLUGDIR)/usb
	@if [ -f usb.usermap ]; then \
		$(INSTALLER) -c -m 0644 -o root -g root usb.usermap $(HOTPLUGDIR) ; \
	else \
		$(INSTALLER) -c -m 0644 -o root -g root usb.usermap.local $(HOTPLUGDIR) && \
		/usr/sbin/update-usb.usermap ; \
	fi
	$(INSTALLER) -c -m 0554 -o root -g root adsl/* $(INSTALLDIR)
	rm -f options.adsl options.mire pap-secrets chap-secrets usb.usermap usb.usermap.local

uninstall:
	rm -f $(PPPDIR)/options.mire
	rm -f $(HOTPLUGDIR)/usb/adiusb*
	./scriptUninst

clean:
	rm -f options.adsl options.mire pap-secrets chap-secrets usb.usermap usb.usermap.local

