-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
ctl_startup
executable file
·108 lines (101 loc) · 3.19 KB
/
ctl_startup
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
#!/bin/tclsh
#
# (C) '2014-2018 by Uwe Langhammer
# script for enabling/disabling server processes
#
# usage: ctl_startup <mode> <reboot> <service1> [<service2> ... <serviceN>]
# mode:0..disable
# mode:1..enable
#
load tclrega.so
set mode [lindex $argv 0]
set reboot_flag [lindex $argv 1]
if {!($mode >= 0 && $mode <= 1) || ($argc < 3)} {
puts "usage: $argv0 0|1 0|1 <service1> \[<service2> ... <serviceN>\]"
exit 1
}
set reboot 0
set i 0
foreach process $argv {
incr i
if {$i <= 2} continue
foreach startscript [glob -nocomplain /etc/init.d/*$process] {
# break
}
if {[info exists startscript] } {
set fp [open $startscript r]
set file_data [read $fp]
set data [split $file_data "\n"]
set line1 [lindex $data 0]
close $fp
set flag 0
if { ($mode == 0) && ($process == "HMServer") } {
puts ""
puts "###############################################################################"
puts "## ##"
puts "## Nach der Deaktivierung sind unter anderem die folgenden CCU2-Funktionen ##"
puts "## nicht mehr moeglich: ##"
puts "## ##"
puts "## - Diagramme ##"
puts "## - Gruppenfunktion (bei Heizungsthermostaten) ##"
puts "## - Erstinitialisierung der SD-Karte ##"
puts "## - Geraetefirmwareupdate ueber WebUI ##"
puts "## - HomeMatic-IP Interface ##"
puts "## ##"
puts "###############################################################################"
puts ""
}
if {[string range $line1 0 3] == "exit"} {
puts "$process in $startscript disabled"
if {$mode != 0} {
puts "enable $process in $startscript"
set flag 1
}
} else {
puts "$process in $startscript enabled"
if {$mode == 0} {
# puts "stop $process"
# exec $startscript stop
puts "disable $process in $startscript"
set flag 1
}
}
if {$flag == 1} {
if {!($reboot == 1)} {
exec mount -o remount,rw /
}
puts "write $startscript"
set fp [open $startscript w 0755]
if {$mode != 0} {
puts -nonewline $fp [join [lreplace $data 0 0] \n]
} else {
puts $fp "exit"
puts -nonewline $fp $file_data
}
close $fp
set reboot 1
}
} else {
puts "$process startscript not found!"
# exit 1
}
}
if {($reboot == 1) && ($reboot_flag == 1)} {
exec mount -o remount,ro /
puts -nonewline "saving DOM..."
flush stdout
catch {
rega system.Save()
}
set result [exec /usr/bin/tail -1 /etc/config/homematic.regadom]
if {$result == "</dom>"} {
puts " OK!"
} else {
puts " XML error!"
exit 1
}
file delete /etc/config/InterfacesList.xml
puts "reboot..."
exec /sbin/reboot
}
exit 0