;=============================================================================
; $VER: Uninstall_Roadshow 1.9 (20.9.2023)
;=============================================================================

; Uninstall Roadshow
(procedure P_Uninstall
(
	(if (askbool
		(prompt (cat
			"This script will attempt to remove Roadshow, deleting the files "
			"copied to your system partition when Roadshow was installed."
			"\n\n"
			"If you made any changes to these files since they were installed "
			"you might want to make a backup copy of the relevant files first."
			"\n\n"
			"Note that uninstalling Roadshow will not remove the drawer "
			"which the documentation was installed in."
			"\n\n"
			"Do you want to uninstall Roadshow?"
		))
		(help (cat
			"Unless you renamed or moved any of the files Roadshow installed on "
			"your system partition, your system partition is write-protected, or "
			"you are using a non-standard set of assignments pointing to your system "
			"partition, this script will delete the files installed for Roadshow."
			"\n\n"
			@askbool-help
		))
	)
	(
		; Delete the shell commands
		(delete "C:AddNetInterface")
		(delete "C:AddNetRoute")
		(delete "C:arp")
		(delete "C:CheckRoadshowConfig")
		(delete "C:ConfigureNetInterface")
		(delete "C:DeleteNetRoute")
		(delete "C:ftp")
		(delete "C:GetNetStatus")
		(delete "C:ipf")
		(delete "C:ipfstat")
		(delete "C:ipmon")
		(delete "C:ipnat")
		(delete "C:ManageNetInterfaces")
		(delete "C:NetLogViewer")
		(delete "C:NetShutdown")
		(delete "C:Offline")
		(delete "C:Online")
		(delete "C:ping")
		(delete "C:ppp_connector")
		(delete "C:ppp_dialer")
		(delete "C:ppp_sample")
		(delete "C:RemoveNetInterface")
		(delete "C:RoadshowControl")
		(delete "C:rsh")
		(delete "C:SampleNetSpeed")
		(delete "C:ShowNetStatus")
		(delete "C:tcpdump")
		(delete "C:traceroute")
		(delete "C:wget")

		(complete 12)

		; Delete the Internet configuration files
		(run "Delete DEVS:Internet ALL QUIET")
		(delete "DEVS:Internet.info")

		(complete 24)

		; Delete the interface configuration files
		(run "Delete DEVS:NetInterfaces ALL QUIET")
		(delete "DEVS:NetInterfaces.info")
		(run "Delete SYS:Storage/NetInterfaces ALL QUIET")
		(delete "SYS:Storage/NetInterfaces.info")

		(complete 36)

		; Delete the PPP/PPPoE drivers
		(delete "DEVS:Networks/ppp-ethernet.device")
		(delete "DEVS:Networks/ppp-serial.device")

		(complete 48)

		; Delete the example files for the firewall and
		; the PPP/PPPoE configuration
		(run "Delete S:IPF ALL QUIET")
		(run "Delete S:PPP-Configurations ALL QUIET")

		(complete 60)

		; Delete the catalog files
		(if (= 2 (exists "LOCALE:Catalogs" (noreq)))
		(
			(delete "LOCALE:catalogs/deutsch/bsdsocket.catalog")
			(delete "LOCALE:catalogs/deutsch/ppp-ethernet.catalog")
			(delete "LOCALE:catalogs/deutsch/ppp-serial.catalog")
			(delete "LOCALE:catalogs/deutsch/roadshow.catalog")
			(delete "LOCALE:catalogs/deutsch/usergroup.catalog")
			(delete "LOCALE:catalogs/polski/bsdsocket.catalog")
			(delete "LOCALE:catalogs/polski/ppp-ethernet.catalog")
			(delete "LOCALE:catalogs/polski/ppp-serial.catalog")
			(delete "LOCALE:catalogs/polski/roadshow.catalog")
			(delete "LOCALE:catalogs/polski/usergroup.catalog")
		))

		(complete 72)

		; Delete the script files
		(delete "S:Check-Firewall-Rules")
		(delete "S:Network-Startup")
		(delete "S:Start-Firewall")
		(delete "S:Stop-Firewall")

		(complete 84)

		; Delete the Roadshow libraries
		(delete "LIBS:bsdsocket.library")
		(delete "LIBS:usergroup.library")

		(complete 100)

		(message "All files installed by Roadshow were deleted.")

		(exit (quiet))
	))
))

;=============================================================================
; Start of uninstallation script
;=============================================================================
(complete 0)

(if (< (/ @installer-version 65536) 43)
(
	(abort (cat
		"This uninstallation script requires the Installer tool V43"
	))
))

; Could this be AmigaOS4?
(if (>= (getversion) (* 50 65536))
(
	(if (not (askbool
		(prompt (cat
			"WARNING:\n\n"
			"Your Amiga appears to be running Amiga operating system version 4 or higher.\n\n"
			"This operating system already ships with the Roadshow TCP/IP stack installed, and "
			"attempting to uninstall this version will damage your system configuration.\n\n"
			"Do you really want to proceed?"
		))
		(default 0)
		(help (cat
			"Your system appears to have the Roadshow TCP/IP stack preinstalled, and unless you are "
			"really, really sure of what you are doing, you should not attempt to uninstall it.\n\n"
			"If in doubt, choose 'No' to stop this uninstallation script."
		))
	))
	(
		(exit (quiet))
	))
))

;=============================================================================

(welcome "Uninstall the Roadshow TCP/IP stack")

(if (= (exists "LIBS:bsdsocket.library" (noreq)) 0)
(
	(message (cat
		"The Roadshow TCP/IP stack does not seem to be installed on your system, "
		"or at least there is no 'bsdsocket.library' found in the LIBS: "
		"directory.\n\n"
		"You may want to verify if there are still parts of Roadshow installed on "
		"your system if you are certain that you previously installed it, or aborted "
		"an installation in progress."
	))
))

(P_Uninstall)
