Code Sample |
#!/bin/flua ww = 400 wh = 120 Fl_Widget.initializers = {textfont=15,labelfont=15,labelcolor=0,scrollbar_width=15} Fl_Window.initializers = {box=Boxtype.thin_down,color=15} Fl_Button.initializers = {box = Boxtype.thin_up, down_box = Boxtype.thin_down} tempfile = "/tmp/lsuci.tempfile" w_main = Window{ww,wh,"UCI files mounted"} file_list = Hold_Browser{10,10,ww-20,wh-50} refresh = Button{40,wh-30,80,20,"refresh"} function refresh.callback() execute("grep \".uci \" /etc/mtab|awk '{print $1}' >"..tempfile) file_list:load(tempfile) remove(tempfile) end umount = Button{ww-120,wh-30,80,20,"umount"} function umount.callback() if file_list.value > 0 then execute("mydsl-load "..file_list:text(file_list.value)) refresh.callback() end end w_main.size_range(w_main,ww,wh) w_main.resizable = file_list refresh.callback() w_main:show() |
Code Sample |
#!/bin/flua -f -- Install and uninstall .UCI-files if getn(arg) == 1 then uci = arg[1] else print("usage: uci-load-choice.lua [uci_name]") exit(1) end local file = openfile("/etc/mtab", "r") -- uci-name l=strlen(uci) for counter=1,l,1 do x = strsub(uci,counter,counter) if x=="/" then lastSlash=counter end end p=(l-lastSlash)*-1 uciFile=strsub(uci,p) --escaping escapedUciFile="" blankFileName=uciFile l=strlen(uciFile) for counter=1,l,1 do x = strsub(uciFile,counter,counter) if x=="-" then x="%-" end escapedUciFile=escapedUciFile..x end uciFile=escapedUciFile -- analyse filetable = {} line = read(file, "*l") while line do if strfind(line,uciFile) then if fl_ask(blankFileName.." is allready mounted!\n\nDo you want to unmount "..blankFileName.."?") then execute("mydsl-load " .. uci ) closefile(file) exit(0) else return end end line = read(file,"*l") end closefile(file) if fl_ask(blankFileName.." is not mounted!\n\nDo you want to mount "..blankFileName.."?") then execute("mydsl-load " .. uci ) exit(0) else exit(0) end |