476d2547e
김태훈
태마루 시스템 설정 / 업데이트...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
package main
import (
"io/ioutil"
"os/exec"
)
func getVersion() string {
env, err := getEnv(1)
if err != nil {
return ""
}
version, exist := env["falinux_version"]
if !exist {
return ""
}
return version
}
func updateSystem() error {
env, err := getEnv(1)
if err != nil {
return err
}
bootpart := env["bootpart"]
var dir string
var partname string
switch bootpart {
case "1":
dir = "/boot1"
partname = "/dev/mmcblk3p2"
env["bootpart"] = "2"
case "2":
dir = "/boot0"
partname = "/dev/mmcblk3p1"
env["bootpart"] = "1"
default:
dir = "/boot0"
partname = "/dev/mmcblk3p1"
env["bootpart"] = "1"
}
if !partitionIsExists() {
makePartition()
} else {
formatPartition(partname)
}
if err := exec.Command("mount", "-o", "rw", dir).Run(); err != nil {
return err
}
defer exec.Command("umount", dir).Run()
if err := exec.Command("unzip", "-o", "/tmp/system.zip", "-d", dir).Run(); err != nil {
return err
}
exec.Command("sync").Run()
if ver, err := ioutil.ReadFile(dir + "/version"); err != nil {
env["falinux_version"] = ""
} else {
env["falinux_version"] = string(ver)
}
return setEnv(1, env)
}
func updateApp() error {
const cmdline = `\
rm -rf /app/bin.old /app/bin.new; \
mkdir /app/bin.new && \
unzip -o /tmp/application.zip -d /app/bin.new && \
sync && \
mv /app/bin /app/bin.old; \
mv /app/bin.new /app/bin; \
sync`
return exec.Command("/bin/sh", "-c", cmdline).Run()
}
func partitionIsExists() bool {
err := exec.Command("test", "-e", "/dev/mmcblk3p1", "-a", "-e", "/dev/mmcblk3p2").Run()
return err == nil
}
func makePartition() {
exec.Command("umount", "/app").Run()
exec.Command("/bin/sh", "-c", "/root/.falinux/mk-mmc-part.sh").Run()
}
func formatPartition(partname string) {
exec.Command("mkfs.fat", partname).Run()
}
func reboot() {
exec.Command("killall", "-19", "watchdog").Run()
exec.Command("reboot").Run()
}
func restore() {
m := make(map[string]string)
setEnv(0, m)
setEnv(1, m)
setEnv(2, m)
setEnv(3, m)
exec.Command("/bin/sh", "-c", "/root/.falinux/mk-mmc-part.sh").Run()
}
|