/etc/cron.d/patch-manager
46 | export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
47 | * * * * * root \${client_path}check-in.sh >/dev/null 2>&1
48 | EOF
49 | else
50 | echo \"Crontab entry already exists in: /etc/cron.d/patch-manager\"
51 | fi
52 | echo \"Client Install completed.\"
53 | ";
54 | echo $script;
55 |
--------------------------------------------------------------------------------
/html/client/get_commands.php:
--------------------------------------------------------------------------------
1 | 0){
38 | $suppression_sql = "SELECT * FROM `supressed` WHERE `server_name` IN (0,'$server_name');";
39 | $suppression_res = mysql_query($sql);
40 | if (mysql_num_rows($suppression_res) > 0) {
41 | while ($suppression_row = mysql_fetch_assoc($suppression_res)){
42 | if (isset($suppression_row['package_name'])) {
43 | $suppression_array[] = $suppression_row['package_name'];
44 | }
45 | }
46 | while ($row3 = mysql_fetch_assoc($res3)){
47 | $package_name = $row3['package_name'];
48 | if (!in_array($package_name, $suppression_array)){
49 | $package_array[] = $package_name;
50 | }
51 | }
52 | foreach ($package_array as $val){
53 | mysql_query("UPDATE `patches` SET `to_upgrade` = 0, `upgraded` = 1 WHERE `server_name` = '$server_name' AND `package_name` = '$val' LIMIT 1;");
54 | }
55 | $package_string = implode(" ", $package_array);
56 | }
57 | }
58 | //CMD GOES HERE
59 | $company = YOUR_COMPANY;
60 | $company_sql = "SELECT * FROM `company` WHERE `display_name`='$company' LIMIT 1;";
61 | $company_res = mysql_query($company_sql);
62 | $company_row = mysql_fetch_array($company_res);
63 | $key_to_check_array = explode(" ",$company_row['install_key']);
64 | $key_to_check = $key_to_check_array[0];
65 | $cmd_sql = "SELECT d.upgrade_command as cmd from servers s left join distro d on s.distro_id=d.id where s.server_name='$server_name' LIMIT 1;";
66 | $cmd_res = mysql_query($cmd_sql);
67 | $cmd_row = mysql_fetch_array($cmd_res);
68 | $cmd = $cmd_row['cmd'];
69 | // If it needs to be rebooted, lets add it on to the end of the rest of the cmd.
70 | if ($to_reboot == 1){
71 | $reboot_cmd_sent_sql = "UPDATE `servers` SET `reboot_cmd_sent`=0 WHERE `id`=$id LIMIT 1;";
72 | mysql_query($reboot_cmd_sent_sql);
73 | $add_after = "/sbin/reboot";
74 | }
75 | else{
76 | $add_after = "";
77 | }
78 | if (isset($package_string)) {
79 | echo "key_to_check='$key_to_check'
80 | cmd_to_run='$cmd $package_string;$add_after'";
81 | } else {
82 | echo "key_to_check='$key_to_check'
83 | cmd_to_run='$add_after'";
84 | }
85 | }
86 | }
87 | mysql_close($link);
88 |
--------------------------------------------------------------------------------
/html/client/index.php:
--------------------------------------------------------------------------------
1 | /dev/null 2>&1
48 | fi
49 |
--------------------------------------------------------------------------------
/html/client/patch_checker.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # generated installation key and server URI from install
4 | auth_key="__SERVER_AUTHKEY_SET_ME__"
5 | server_uri="__SERVER_URI_SET_ME__"
6 | submit_patch_uri="${server_uri}client/send_patches.php"
7 | # set client_path
8 | if [[ -d /opt/patch_client ]]; then
9 | client_path="/opt/patch_client/"
10 | else
11 | client_path="/opt/patch_manager/"
12 | fi
13 | # if $client_path does not exist
14 | if [[ ! -f "${client_path}.patchrc" ]]; then
15 | echo "Please run ${client_path}check-in.sh as root (sudo) before trying to run this manually"
16 | exit 0
17 | fi
18 | # load the file
19 | . ${client_path}.patchrc
20 | rm -rf /tmp/patch_$client_key > /dev/null 2>&1
21 | if [[ -f /etc/lsb-release && -f /etc/debian_version ]]; then
22 | os=$(lsb_release -s -d|head -1|awk {'print $1'})
23 | elif [[ -f /etc/debian_version ]]; then
24 | os="$(cat /etc/issue|head -n 1|awk {'print $1'})"
25 | elif [[ -f /etc/redhat-release ]]; then
26 | os=$(cat /etc/redhat-release|head -1|awk {'print $1'})
27 | if [[ "$os" = "Red" && $(grep -i enterprise /etc/redhat-release) != "" ]]; then
28 | os="RHEL"
29 | elif [[ "$os" = "Red" ]]; then
30 | os="RHEL"
31 | fi
32 | else
33 | os=$(uname -s -r|head -1|awk {'print $1'})
34 | fi
35 | # remove any special characters
36 | os=$(echo $os|sed -e 's/[^a-zA-Z0-9]//g')
37 | # begin update checks
38 | if [[ "$os" = "CentOS" ]] || [[ "$os" = "Fedora" ]] || [[ "$os" = "RHEL" ]]; then
39 | need_patched="true"
40 | yum -q check-update| while read i
41 | do
42 | i=$(echo $i) #this strips off yum's irritating use of whitespace
43 | if [[ "${i}x" != "x" ]]
44 | then
45 | UVERSION=${i#*\ }
46 | UVERSION=${UVERSION%\ *}
47 | PNAME=${i%%\ *}
48 | PNAME=${PNAME%.*}
49 | #echo $(rpm -q "${PNAME}" --qf '%{NAME}:::%{VERSION}:::')${UVERSION}
50 | patches_to_install=$(echo $(rpm -q "${PNAME}" --qf '%{NAME}:::%{VERSION}:::')${UVERSION})
51 | echo "$patches_to_install" >> /tmp/patch_$client_key
52 | fi
53 | done
54 | elif test "$os" = Ubuntu -o "$os" = Debian -o "$os" = Devuan -o "$os" = Raspbian; then
55 | need_patched="true"
56 | #apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "$1:::$2:::$3\n"}'
57 | patches_to_install=$(apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "$1:::$2:::$3\n"}')
58 | echo "$patches_to_install" >> /tmp/patch_$client_key
59 | elif [[ "$os" = "Linux" ]]; then
60 | echo "unspecified $os not supported"
61 | exit 0
62 | fi
63 | if [[ "$need_patched" == "true" ]]; then
64 | patch_list=$(cat /tmp/patch_$client_key)
65 | curl -k -s -H "X-CLIENT-KEY: $client_key" $submit_patch_uri -d "$patch_list"
66 | rm -rf /tmp/patch_$client_key > /dev/null 2>&1
67 | fi
68 |
69 |
--------------------------------------------------------------------------------
/html/client/run_commands.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | auth_key="__SERVER_AUTHKEY_SET_ME__"
3 | server_uri="__SERVER_URI_SET_ME__"
4 | get_cmd_uri="${server_uri}client/get_commands.php"
5 | # set client_path
6 | if [[ -d /opt/patch_client ]]; then
7 | client_path="/opt/patch_client/"
8 | else
9 | client_path="/opt/patch_manager/"
10 | fi
11 | # force a run of check-in.sh if .patchrc is missing.
12 | if [[ ! -f "${client_path}.patchrc" ]]; then
13 | echo "Please run ${client_path}check-in.sh as root (sudo) before trying to run this manually"
14 | exit 0
15 | fi
16 | . ${client_path}.patchrc
17 | rm -rf /tmp/cmds_$client_key > /dev/null 2>&1
18 | curl -k -s -H "X-CLIENT-KEY: $client_key" $get_cmd_uri > /tmp/cmds_$client_key
19 | cmds_line_count=$(cat /tmp/cmds_$client_key|wc -l)
20 | if [ "$cmds_line_count" -gt "0" ]; then
21 | . /tmp/cmds_$client_key
22 | key_sum=$(echo $key_to_check|sha256sum)
23 | auth_sum=$(echo $auth_key|sha256sum)
24 | if [ "$key_sum" == "$auth_sum" ]; then
25 | echo $cmd_to_run|bash
26 | fi
27 | fi
28 | rm -rf /tmp/cmds_$client_key
29 |
--------------------------------------------------------------------------------
/html/client/send_packages.php:
--------------------------------------------------------------------------------
1 | /dev/null|grep ''|head -1\"");
31 | $url = str_replace(" | /dev/null|grep '$package_to'|grep 'urgency='\"");
35 | if (stristr($urgency_curl, "emergency")) {
36 | $urgency = "emergency";
37 | } elseif (stristr($urgency_curl, "high")) {
38 | $urgency = "high";
39 | } elseif (stristr($urgency_curl, "medium")) {
40 | $urgency = "medium";
41 | } elseif (stristr($urgency_curl, "low")) {
42 | $urgency = "low";
43 | } else {
44 | $urgency = "unknown";
45 | }
46 | if (!in_array($package_name, $suppression_array)) {
47 | $sql = "INSERT INTO patches(server_name,package_name,current,new,urgency,bug_url) VALUES('$server_name','$package_name','$package_from','$package_to','$urgency','$the_url');";
48 | mysql_query($sql);
49 | }
50 | }
51 | }
52 | mysql_close();
53 |
--------------------------------------------------------------------------------
/html/css/bootstrap-switch.min.css:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * bootstrap-switch - v3.2.2
3 | * http://www.bootstrap-switch.org
4 | * ========================================================================
5 | * Copyright 2012-2013 Mattia Larentis
6 | *
7 | * ========================================================================
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | * ========================================================================
20 | */
21 |
22 | .bootstrap-switch{display:inline-block;cursor:pointer;border-radius:4px;border:1px solid;border-color:#ccc;position:relative;text-align:left;overflow:hidden;line-height:8px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;vertical-align:middle;-webkit-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.bootstrap-switch .bootstrap-switch-container{display:inline-block;top:0;border-radius:4px;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.bootstrap-switch .bootstrap-switch-handle-on,.bootstrap-switch .bootstrap-switch-handle-off,.bootstrap-switch .bootstrap-switch-label{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;cursor:pointer;display:inline-block!important;height:100%;padding:6px 12px;font-size:14px;line-height:20px}.bootstrap-switch .bootstrap-switch-handle-on,.bootstrap-switch .bootstrap-switch-handle-off{text-align:center;z-index:1}.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-primary,.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-primary{color:#fff;background:#428bca}.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-info,.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-info{color:#fff;background:#5bc0de}.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-success,.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-success{color:#fff;background:#5cb85c}.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-warning,.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-warning{background:#f0ad4e;color:#fff}.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-danger,.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-danger{color:#fff;background:#d9534f}.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-default,.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-default{color:#000;background:#eee}.bootstrap-switch .bootstrap-switch-label{text-align:center;margin-top:-1px;margin-bottom:-1px;z-index:100;color:#333;background:#fff}.bootstrap-switch .bootstrap-switch-handle-on{border-bottom-left-radius:3px;border-top-left-radius:3px}.bootstrap-switch .bootstrap-switch-handle-off{border-bottom-right-radius:3px;border-top-right-radius:3px}.bootstrap-switch input[type=radio],.bootstrap-switch input[type=checkbox]{position:absolute!important;top:0;left:0;opacity:0;filter:alpha(opacity=0);z-index:-1}.bootstrap-switch input[type=radio].form-control,.bootstrap-switch input[type=checkbox].form-control{height:auto}.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-label{padding:1px 5px;font-size:12px;line-height:1.5}.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-label{padding:5px 10px;font-size:12px;line-height:1.5}.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-label{padding:6px 16px;font-size:18px;line-height:1.33}.bootstrap-switch.bootstrap-switch-disabled,.bootstrap-switch.bootstrap-switch-readonly,.bootstrap-switch.bootstrap-switch-indeterminate{cursor:default!important}.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label{opacity:.5;filter:alpha(opacity=50);cursor:default!important}.bootstrap-switch.bootstrap-switch-animate .bootstrap-switch-container{-webkit-transition:margin-left .5s;transition:margin-left .5s}.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-on{border-bottom-left-radius:0;border-top-left-radius:0;border-bottom-right-radius:3px;border-top-right-radius:3px}.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-off{border-bottom-right-radius:0;border-top-right-radius:0;border-bottom-left-radius:3px;border-top-left-radius:3px}.bootstrap-switch.bootstrap-switch-focused{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-label{border-bottom-right-radius:3px;border-top-right-radius:3px}.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-label{border-bottom-left-radius:3px;border-top-left-radius:3px}
23 |
--------------------------------------------------------------------------------
/html/css/bootstrapValidator.min.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * BootstrapValidator (http://bootstrapvalidator.com)
3 | * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
4 | *
5 | * @version v0.5.3, built on 2014-11-05 9:14:18 PM
6 | * @author https://twitter.com/nghuuphuoc
7 | * @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
8 | * @license Commercial: http://bootstrapvalidator.com/license/
9 | * Non-commercial: http://creativecommons.org/licenses/by-nc-nd/3.0/
10 | */
11 |
12 | .bv-form .help-block{margin-bottom:0}.bv-form .tooltip-inner{text-align:left}.nav-tabs li.bv-tab-success>a{color:#3c763d}.nav-tabs li.bv-tab-error>a{color:#a94442}.bv-form .bv-icon-no-label{top:0}.bv-form .bv-icon-input-group{top:0;z-index:100}
13 |
--------------------------------------------------------------------------------
/html/css/dashboard.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Base structure
3 | */
4 |
5 | /* Move down content because we have a fixed navbar that is 50px tall */
6 | body {
7 | padding-top: 50px;
8 | }
9 |
10 |
11 | /*
12 | * Global add-ons
13 | */
14 |
15 | .sub-header {
16 | padding-bottom: 10px;
17 | border-bottom: 1px solid #eee;
18 | }
19 |
20 |
21 | /*
22 | * Sidebar
23 | */
24 |
25 | /* Hide for mobile, show later */
26 | .sidebar {
27 | display: none;
28 | }
29 | @media (min-width: 768px) {
30 | .sidebar {
31 | position: fixed;
32 | top: 51px;
33 | bottom: 0;
34 | left: 0;
35 | z-index: 1000;
36 | display: block;
37 | padding: 20px;
38 | overflow-x: hidden;
39 | overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
40 | background-color: #f5f5f5;
41 | border-right: 1px solid #eee;
42 | }
43 | }
44 |
45 | /* Sidebar navigation */
46 | .nav-sidebar {
47 | margin-right: -21px; /* 20px padding + 1px border */
48 | margin-bottom: 20px;
49 | margin-left: -20px;
50 | }
51 | .nav-sidebar > li > a {
52 | padding-right: 20px;
53 | padding-left: 20px;
54 | }
55 | .nav-sidebar > .active > a {
56 | color: #fff;
57 | background-color: #428bca;
58 | }
59 |
60 |
61 | /*
62 | * Main content
63 | */
64 |
65 | .main {
66 | padding: 20px;
67 | }
68 | @media (min-width: 768px) {
69 | .main {
70 | padding-right: 40px;
71 | padding-left: 40px;
72 | }
73 | }
74 | .main .page-header {
75 | margin-top: 0;
76 | }
77 |
78 |
79 | /*
80 | * Placeholder dashboard ideas
81 | */
82 |
83 | .placeholders {
84 | margin-bottom: 30px;
85 | text-align: center;
86 | }
87 | .placeholders h4 {
88 | margin-bottom: 0;
89 | }
90 | .placeholder {
91 | margin-bottom: 20px;
92 | }
93 | .placeholder img {
94 | display: inline-block;
95 | border-radius: 50%;
96 | }
97 |
--------------------------------------------------------------------------------
/html/css/index.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | 
4 |
5 | Oops!
6 |
7 | 404 Not Found
8 |
9 | Sorry, an error has occurred, The page you requested was not found!
10 |
11 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/html/inc/404_footer.inc.php:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 | |