Skip to content

Commit

Permalink
lime-system: avoid concurrent execution of lime-config
Browse files Browse the repository at this point in the history
  • Loading branch information
frank95 committed Aug 10, 2014
1 parent 1243989 commit 8ca6b9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
7 changes: 2 additions & 5 deletions packages/lime-system/files/etc/lime-defaults/10-lime_config
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/bin/sh
sleep 90s
echo "Configuring LiMe for first time..."
lua /usr/bin/lime-config
uci commit
reboot
echo "Configuring LiMe for first time, will take apprex 2 minutes..."
(sleep 90s ; lua /usr/bin/lime-config && uci commit && reboot)&);
18 changes: 17 additions & 1 deletion packages/lime-system/files/usr/bin/lime-config
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,20 @@ function main()
for _, module in pairs(modules) do module.configure() end
end

main()

local lockFilePath = "/var/run/lime-config.pid"
local lockFile = io.open(lockFilePath,"r")
if lockFile then
lockFile:close()
print("lime-config already running")
else
lockFile = io.open(lockFilePath,"w")
local statFile = io.open("/proc/self/stat", "r")
lockFile:write(statFile:read("*n"))
statFile:close()

main()

lockFile:close()
os.remove(lockFilePath)
end

0 comments on commit 8ca6b9a

Please sign in to comment.