FileDocCategorySizeDatePackage
ScriptAfterShutdown.javaAPI DocAzureus 3.0.3.41634Tue Aug 07 11:24:16 BST 2007org.gudy.azureus2.platform.unix

ScriptAfterShutdown

public class ScriptAfterShutdown extends Object

Fields Summary
private static PrintStream
sysout
Constructors Summary
Methods Summary
public static voidaddExtraCommand(java.lang.String s)

		String extraCmds = COConfigurationManager.getStringParameter(
				"scriptaftershutdown", null);
		if (extraCmds == null) {
			extraCmds = s + "\n";
		} else {
			extraCmds += s + "\n";
		}
		COConfigurationManager.setParameter("scriptaftershutdown", extraCmds);
	
private static voidlog(java.lang.String string)

		sysout.println("echo \"" + string.replaceAll("\"", "\\\"") + "\"");
	
public static voidmain(java.lang.String[] args)

		// Since stdout will be in a shell script, redirect any stdout not coming
		// from us to stderr 
		sysout = System.out;
		try {
			System.setOut(new PrintStream(new FileOutputStream("/dev/stderr")));
		} catch (FileNotFoundException e) {
		}

		String extraCmds = COConfigurationManager.getStringParameter(
				"scriptaftershutdown", null);
		if (extraCmds != null) {
			boolean exit = COConfigurationManager.getBooleanParameter(
					"scriptaftershutdown.exit", false);
			if (exit) {
				COConfigurationManager.removeParameter("scriptaftershutdown.exit");
			}
			COConfigurationManager.removeParameter("scriptaftershutdown");
			COConfigurationManager.save();
			sysout.println(extraCmds);
			if (exit) {
				sysout.println("exit");
			}
		} else {
			log("No shutdown tasks to do");
		}
	
public static voidsetRequiresExit(boolean requiresExit)

		if (requiresExit) {
			COConfigurationManager.setParameter("scriptaftershutdown.exit", true);
		}