Changeset 8558
- Timestamp:
- 04/15/12 16:30:54 (14 months ago)
- Files:
-
- 1 modified
-
luci/trunk/libs/sys/luasrc/sys.lua (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/libs/sys/luasrc/sys.lua
r8045 r8558 308 308 309 309 net.routes6(function(rt) 310 if rt.dest:prefix() == 0 and rt.device ~= "lo" and 310 if rt.dest:prefix() == 0 and rt.device ~= "lo" and 311 311 (not route or route.metric > rt.metric) 312 312 then … … 791 791 end 792 792 793 --- Test whether the given init script is enabled794 -- @param name Name of the init script795 -- @return Boolean indicating whether init is enabled796 function init.enabled(name)797 if fs.access(init.dir..name) then798 return ( call(init.dir..name.." enabled >/dev/null") == 0 )799 end800 return false801 end802 803 793 --- Get the index of he given init script 804 794 -- @param name Name of the init script … … 806 796 function init.index(name) 807 797 if fs.access(init.dir..name) then 808 return call("source "..init.dir..name.." enabled >/dev/null; exit $START") 809 end 798 return call("env -i sh -c 'source %s%s; exit $START' >/dev/null" 799 %{ init.dir, name }) 800 end 801 end 802 803 local function init_action(action, name) 804 if fs.access(init.dir..name) then 805 return call("env -i %s%s %s >/dev/null" %{ init.dir, name, action }) 806 end 807 end 808 809 --- Test whether the given init script is enabled 810 -- @param name Name of the init script 811 -- @return Boolean indicating whether init is enabled 812 function init.enabled(name) 813 return (init_action("enabled", name) == 0) 810 814 end 811 815 … … 814 818 -- @return Boolean indicating success 815 819 function init.enable(name) 816 if fs.access(init.dir..name) then 817 return ( call(init.dir..name.." enable >/dev/null") == 1 ) 818 end 820 return (init_action("enable", name) == 1) 819 821 end 820 822 … … 823 825 -- @return Boolean indicating success 824 826 function init.disable(name) 825 if fs.access(init.dir..name) then 826 return ( call(init.dir..name.." disable >/dev/null") == 0 ) 827 end 827 return (init_action("disable", name) == 0) 828 end 829 830 --- Start the given init script 831 -- @param name Name of the init script 832 -- @return Boolean indicating success 833 function init.start(name) 834 return (init_action("start", name) == 0) 835 end 836 837 --- Stop the given init script 838 -- @param name Name of the init script 839 -- @return Boolean indicating success 840 function init.stop(name) 841 return (init_action("stop", name) == 0) 828 842 end 829 843
