Skip to content

Commit

Permalink
ncp-web: implement dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Apr 3, 2018
1 parent b94bcb4 commit fa1ec75
Show file tree
Hide file tree
Showing 10 changed files with 282 additions and 82 deletions.
13 changes: 6 additions & 7 deletions bin/ncp-diag
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ echo "datadir|$DATADIR$DIRINFO"
echo "data disk usage|$( df -h "$DATADIR" | tail -1 | awk '{ print $3"/"$2 }')"
}
echo "rootfs usage|$( df -h / | tail -1 | awk '{ print $3"/"$2 }')"
echo "swapfile|$( swapon | tail -1 | awk '{ print $1 }' )"
SWP="$( swapon | tail -1 | awk '{ print $1 }' )"
[[ "$SWP" == "" ]] && SWP="none"
echo "swapfile|$SWP"

# Nextcloud
VERSION="$( sudo -u www-data php /var/www/nextcloud/occ status | grep "version:" | awk '{ print $3 }' )"
VERSION="$( php /var/www/nextcloud/occ status | grep "version:" | awk '{ print $3 }' )"
if [[ "$VERSION" != "" ]]; then
echo "Nextcloud check|ok"
echo "Nextcloud version|$VERSION"
Expand Down Expand Up @@ -75,13 +77,10 @@ echo "gateway|$GW"
echo "interface|$IFACE"

# Certificates
LEOUT="$( /etc/letsencrypt/letsencrypt-auto certificates 2>/dev/null )"
CERTS="$( echo -e "$LEOUT" | grep "Domains:" | awk '{ print $2 }' | tr '\n' ' ' )"
CDUE="$( echo -e "$LEOUT" | grep "VALID:" | grep -oP "\d+ days" | tr '\n' ' ' )"
CERTS="$( grep "SSLCertificateFile /etc/letsencrypt/live/" /etc/apache2/sites-available/nextcloud.conf \
| sed 's|.*SSLCertificateFile /etc/letsencrypt/live/||;s|/fullchain.pem||' )"
[[ "$CERTS" == "" ]] && CERTS=none
[[ "$CDUE" == "" ]] && CDUE=none
echo "certificates|$CERTS"
echo "certs due|$CDUE"

RESOLV="$( ping -c 1 "$CERTS" 2>/dev/null | head -1 | grep -oP '\d{1,3}(.\d{1,3}){3}' )"
echo "NAT loopback|$( [[ "$RESOLV" == "$IP" ]] && echo yes || echo no )"
Expand Down
2 changes: 1 addition & 1 deletion bin/ncp-report
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ echo "<--! Paste this in GitHub report -->"
##

open_summary "NextCloudPi diagnostics"
ncp-diag | column -t -s'|'
bash /usr/local/bin/ncp-diag | column -t -s'|'
close_summary

##
Expand Down
38 changes: 38 additions & 0 deletions bin/ncp-suggestions
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

#
# NextCloudPi configuration suggestions
#
# Copyleft 2018 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
# Usage:
# sudo ncp-suggestions "$( ncp-diag )"
#
# More at https://ownyourbits.com
#

OUT="$@"

DNSMASQ_ON="$( grep "^ACTIVE_=" /usr/local/etc/nextcloudpi-config.d/dnsmasq.sh | cut -d'=' -f2 )"

grep -q "distribution|.*bian GNU/Linux 9" <<<"$OUT" || \
echo -e "You are using an unsupported distro release. Please upgrade to latest Debian/Raspbian"

[[ $DNSMASQ_ON != "yes" ]] && \
grep -q "NAT loopback|no" <<<"$OUT" && \
echo -e "\nYou should enable dnsmasq to use your domain inside home"

grep -q "certificates|none" <<<"$OUT" && \
echo -e "\nYou should run Lets Encrypt for trusted encrypted access"

grep -q "port check .*|closed" <<<"$OUT" && \
echo -e "\nYou should open your ports for Lets Encrypt and external access"

grep -q "USB devices|none" <<<"$OUT" || {
grep -q "data in SD|yes" <<<"$OUT" && \
echo -e "\nYou should use nc-datadir to move your files to your plugged in USB drive"

grep -q "automount|no" <<<"$OUT" && \
echo -e "\nYou should enable automount to use your plugged in USB drive"
}
8 changes: 6 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

[v0.53.8](https://github.com/nextcloud/nextcloudpi/commit/cc733af) (2018-04-02) ncp-web: fix update notification
[v0.53.10](https://github.com/nextcloud/nextcloudpi/commit/dce58cc) (2018-04-03) ncp-web: implement dashboard

[v0.53.7](https://github.com/nextcloud/nextcloudpi/commit/d4ca26a) (2018-03-29) ncp-web: use random passwords for NC and ncp-web
[v0.53.9](https://github.com/nextcloud/nextcloudpi/commit/486d6ef) (2018-04-02) SSH: stop service upon activation

[v0.53.8 ](https://github.com/nextcloud/nextcloudpi/commit/afd2c8e) (2018-04-02) ncp-web: fix update notification

[v0.53.7 ](https://github.com/nextcloud/nextcloudpi/commit/d4ca26a) (2018-03-29) ncp-web: use random passwords for NC and ncp-web

[v0.53.6 ](https://github.com/nextcloud/nextcloudpi/commit/151160b) (2018-03-27) samba: dont force NAME_REGEX for username

Expand Down
35 changes: 7 additions & 28 deletions etc/nextcloudpi-config.d/nc-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# Usage:
#
# ./installer.sh nc-diag.sh <IP> (<img>)
# ./installer.sh nc-info.sh <IP> (<img>)
#
# See installer.sh instructions for details
# More at: https://ownyourbits.com
Expand All @@ -17,36 +17,16 @@ DESCRIPTION="Print NextCloudPi system info"

configure()
{
# info

local OUT="$( ncp-diag )"
echo "Gathering information..."
local OUT="$( bash /usr/local/bin/ncp-diag )"

# info
echo "$OUT" | column -t -s'|'

# suggestions

DNSMASQ_ON="$( grep "^ACTIVE_=" /usr/local/etc/nextcloudpi-config.d/dnsmasq.sh | cut -d'=' -f2 )"

grep -q "distribution|.*bian GNU/Linux 9" <<<"$OUT" || \
echo -e "\nYou are using an unsupported distro release. Please upgrade to latest Debian/Raspbian"

[[ $DNSMASQ_ON != "yes" ]] && \
grep -q "NAT loopback|no" <<<"$OUT" && \
echo -e "\nYou should enable dnsmasq to use your domain inside home"

grep -q "certificates|none" <<<"$OUT" && \
echo -e "\nYou should run Lets Encrypt for trusted encrypted access"

grep -q "port check .*|closed" <<<"$OUT" && \
echo -e "\nYou should open your ports for Lets Encrypt and external access"

grep -q "USB devices|none" <<<"$OUT" || {
grep -q "data in SD|yes" <<<"$OUT" && \
echo -e "\nYou should use nc-datadir to move your files to your plugged in USB drive"

grep -q "automount|no" <<<"$OUT" && \
echo -e "\nYou should enable automount to uyyse your plugged in USB drive"
}
echo
bash /usr/local/bin/ncp-suggestions "$OUT"

return 0
}

Expand All @@ -68,4 +48,3 @@ install() { :; }
# along with this script; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA

65 changes: 65 additions & 0 deletions ncp-web/img/dashboard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 33 additions & 18 deletions ncp-web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
</a>
</div>
<div id="header-right">
<div id="dashboard-btn">
<div id="expand">
<div class="icon-dashboard"></div>
</div>
</div>
<?php
if ( file_exists( 'wizard' ) )
echo <<<HTML
Expand Down Expand Up @@ -139,7 +144,7 @@
<?php

// fill options with contents from directory
$files = array_diff(scandir($modules_path), array('.', '..', 'nc-wifi.sh', 'l10n'));
$files = array_diff(scandir($modules_path), array('.', '..', 'nc-wifi.sh', 'nc-info.sh', 'l10n'));

foreach ($files as $file) {
$script = pathinfo($file, PATHINFO_FILENAME);
Expand Down Expand Up @@ -169,24 +174,33 @@

<div id="app-content">
<div id="app-navigation-toggle" class="icon-menu hidden"></div>
<h2 id="config-box-title"><?php echo $l->__("Configure NextCloudPi features"); ?></h2>
<a href="#" target="_blank">
<div id="config-extra-info" class="icon-info"></div>
</a>
<div id="config-box-info"></div>
<br/>
<div id="config-box-wrapper" class="hidden">
<form>
<div id="config-box"></div>
<div id="config-button-wrapper">
<button id="config-button"><?php echo $l->__("Run"); ?></button>
<img id="loading-gif" src="img/loading-small.gif">
<div id="circle-retstatus" class="icon-red-circle"></div>
</div>
</form>
<textarea readonly id="details-box" rows="12"></textarea>

<div id="config-wrapper" class="hidden">
<h2 id="config-box-title" class="text-title"><?php echo $l->__("System Info"); ?></h2>
<div id="config-box-info-txt"></div>
<a href="#" target="_blank">
<div id="config-extra-info" class="icon-info"></div>
</a>
<br/>
<div id="config-box-wrapper" class="table-wrapper">
<form>
<div id="config-box"></div>
<div id="config-button-wrapper">
<button id="config-button"><?php echo $l->__("Run"); ?></button>
<img id="loading-gif" src="img/loading-small.gif">
<div id="circle-retstatus" class="icon-red-circle"></div>
</div>
</form>
<textarea readonly id="details-box" class="outputbox" rows="12"></textarea>
</div>
</div>

<div id="dashboard-wrapper">
<h2 class="text-title"><?php echo $l->__("System Info"); ?></h2>
<div id="dashboard-suggestions" class="table-wrapper"></div>
<div id="dashboard-table" class="outputbox table-wrapper"></div>
</div>
<div id="loading-info-gif"> <img src="img/loading-small.gif"> </div>
</div>

<div id="poweroff-dialog" class='dialog primary hidden'>
Expand All @@ -200,7 +214,8 @@

<?php
include('csrf.php');
echo '<input type="hidden" id="csrf-token" name="csrf-token" value="' . getCSRFToken() . '"/>';
echo '<input type="hidden" id="csrf-token" name="csrf-token" value="' . getCSRFToken() . '"/>';
echo '<input type="hidden" id="csrf-token-dash" name="csrf-token-dash" value="' . getCSRFToken() . '"/>';
?>
<script src="minified.js"></script>
<script src="ncp.js"></script>
Expand Down
Loading

0 comments on commit fa1ec75

Please sign in to comment.