Skip to content

Commit 465e8bf

Browse files
committed
system reboot
1 parent f615091 commit 465e8bf

File tree

6 files changed

+157
-8
lines changed

6 files changed

+157
-8
lines changed

bin/v-list-sys-info

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ARCH=$(arch)
5252

5353
# Check uptime
5454
UPTIME=$(cat /proc/uptime |cut -f 1 -d ' '|cut -f 1 -d .)
55-
UPTIME="$(echo $UPTIME / 3600 | bc)"
55+
UPTIME="$(echo $UPTIME / 60 | bc)"
5656

5757
# Check LoadAverage
5858
LOADAVERAGE=$(cat /proc/loadavg |cut -f 1 -d ' ')
@@ -61,21 +61,22 @@ LOADAVERAGE=$(cat /proc/loadavg |cut -f 1 -d ' ')
6161
tmp_file=$(mktemp)
6262

6363
# Define key/value pairs
64-
str="HOSTNAME='$HOSTNAME' OS='$OS' VERSION='$VERSION' ARCH='$ARCH'"
65-
str="$str UPTIME='$UPTIME' LOADAVERAGE='$LOADAVERAGE'"
64+
str="SYS='sysinfo' HOSTNAME='$HOSTNAME' OS='$OS' VERSION='$VERSION'"
65+
str="$str ARCH='$ARCH' UPTIME='$UPTIME' LOADAVERAGE='$LOADAVERAGE'"
6666

6767
# Defining config
6868
echo -e "$str" > $tmp_file
6969
conf=$tmp_file
7070

7171
# Defining fileds to select
72-
fields="\$HOSTNAME \$OS \$VERSION \$ARCH \$UPTIME \$LOADAVERAGE"
72+
fields="\$SYS \$HOSTNAME \$OS \$VERSION \$ARCH \$UPTIME \$LOADAVERAGE"
7373

7474
# Listing services
7575
case $format in
7676
json) json_list ;;
7777
plain) nohead=1; shell_list ;;
78-
shell) shell_list | column -t ;;
78+
shell) fields="\$HOSTNAME \$OS \$VERSION \$ARCH \$UPTIME \$LOADAVERAGE"
79+
shell_list | column -t ;;
7980
*) check_args '1' '0' 'USER [FORMAT]'
8081
esac
8182

bin/v-restart-system

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# info: restart operating system
3+
# options: restart
4+
#
5+
# The function restarts operating system.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
restart=$1
14+
15+
# Includes
16+
source $VESTA/func/main.sh
17+
18+
19+
#----------------------------------------------------------#
20+
# Verifications #
21+
#----------------------------------------------------------#
22+
23+
check_args '1' "$#" 'RESTART'
24+
25+
26+
#----------------------------------------------------------#
27+
# Action #
28+
#----------------------------------------------------------#
29+
30+
if [ "$restart" = 'yes' ]; then
31+
/sbin/reboot
32+
fi
33+
34+
35+
#----------------------------------------------------------#
36+
# Vesta #
37+
#----------------------------------------------------------#
38+
39+
exit

web/bulk/service/index.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
break;
2020
default: header("Location: /list/services/"); exit;
2121
}
22+
23+
if ((!empty($_POST['system'])) && ($action == 'restart')) {
24+
exec (VESTA_CMD."v-restart-system yes", $output, $return_var);
25+
$_SESSION['error_srv'] = 'The system is going down for reboot NOW!';
26+
unset($output);
27+
header("Location: /list/services/");
28+
exit;
29+
}
30+
2231
foreach ($service as $value) {
2332
$value = escapeshellarg($value);
2433
exec (VESTA_CMD.$cmd." ".$value, $output, $return_var);

web/list/services/index.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
// Data
1515
if ($_SESSION['user'] == 'admin') {
16+
exec (VESTA_CMD."v-list-sys-info json", $output, $return_var);
17+
$sys = json_decode(implode('', $output), true);
18+
unset($output);
1619
exec (VESTA_CMD."v-list-sys-services json", $output, $return_var);
1720
$data = json_decode(implode('', $output), true);
1821
unset($output);

web/restart/system/index.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
// Init
3+
error_reporting(NULL);
4+
ob_start();
5+
session_start();
6+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
7+
8+
if ($_SESSION['user'] == 'admin') {
9+
if (!empty($_GET['hostname'])) {
10+
exec (VESTA_CMD."v-restart-system yes", $output, $return_var);
11+
$_SESSION['error_srv'] = 'The system is going down for reboot NOW!';
12+
}
13+
unset($output);
14+
}
15+
16+
header("Location: /list/services/");
17+
exit;

web/templates/admin/list_services.html

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
});
3636
});
3737
</script>
38-
<div id="dialog-message" title="Error">
38+
<div id="dialog-message" title="">
3939
<p><?php echo $_SESSION['error_srv'] ?></p>
4040
</div>
4141
</div>
@@ -50,6 +50,86 @@
5050

5151
<div id="vstobjects">
5252
<table class='data'>
53+
<tr class="data-row"">
54+
<td class="data-dotted" width="150">
55+
<table class="data-col1">
56+
<tr><td><input type="checkbox" class="ch-toggle" name="system[]" value="<?php echo $sys['sysinfo']['HOSTNAME'] ?>" ></td></tr>
57+
<tr><td class="data-active"><b><?php echo 'running' ?></b></td></tr>
58+
</table>
59+
</td>
60+
<td class="data-dotted" width="830px">
61+
<a href="/restart/system/?hostname=<?php echo $sys['sysinfo']['HOSTNAME'] ?>" class="data-controls">
62+
<span>
63+
<img src="/images/reload.png" width="6px" height="7px">
64+
<?php print __('restart'); ?>
65+
</span>
66+
</a>
67+
<table class="data-col2" width="830px">
68+
<tr>
69+
<td colspan=4 class="domain" style="padding: 0 0 0 4px;">
70+
<b><?php echo $sys['sysinfo']['HOSTNAME'] ?></b>
71+
</td>
72+
</tr>
73+
<tr>
74+
<td style="vertical-align:top;" width="354px">
75+
<table>
76+
<tr>
77+
<td>
78+
<a class="counter-name">
79+
<?php print __('Operating System'); ?>:
80+
</a>
81+
</td>
82+
<td>
83+
<a class="counter-value">
84+
<?php echo $sys['sysinfo']['OS'] ?>
85+
<?php echo $sys['sysinfo']['VERSION'] ?>
86+
(<?php echo $sys['sysinfo']['ARCH'] ?>)
87+
</a>
88+
</td>
89+
90+
</tr>
91+
</table>
92+
</td>
93+
<td style="vertical-align:top;" width="142px">
94+
<table>
95+
<tr>
96+
<td class="counter-name">
97+
<?php print __('LoadAverage');?>:
98+
</td>
99+
<td>
100+
<a class="counter-value"> <?php echo $sys['sysinfo']['LOADAVERAGE'] ?></a>
101+
</td>
102+
</tr>
103+
</table>
104+
</td>
105+
<td style="vertical-align:top;" width="34px">
106+
<table>
107+
<tr>
108+
<td class="counter-name">
109+
</td>
110+
<td>
111+
</td>
112+
</tr>
113+
</table>
114+
</td>
115+
<td style="vertical-align:top;" widht="280px">
116+
<table>
117+
<tr>
118+
<td class="counter-name">
119+
<?php print __('Uptime');?>:
120+
</td>
121+
<td>
122+
<a class="counter-value"><?php echo humanize_time($sys['sysinfo']['UPTIME']) ?> </a>
123+
</td>
124+
</tr>
125+
</table>
126+
</td>
127+
</tr>
128+
</table>
129+
</td>
130+
</tr>
131+
132+
53133

54134
<?php
55135
foreach ($data as $key => $value) {
@@ -107,7 +187,7 @@
107187
<td style="vertical-align:top;" width="150px">
108188
<table>
109189
<tr>
110-
<td class="counter-name">
190+
<td class="counter-name" widht="">
111191
<?php print __('CPU');?>:
112192
</td>
113193
<td>
@@ -128,7 +208,7 @@
128208
</tr>
129209
</table>
130210
</td>
131-
<td style="vertical-align:top;" >
211+
<td style="vertical-align:top;">
132212
<table>
133213
<tr>
134214
<td class="counter-name">

0 commit comments

Comments
 (0)