Permalink
Browse files

Add authentication to NEMS Cloud

  • Loading branch information...
NEMS Linux
NEMS Linux committed Oct 26, 2018
1 parent 34dbf06 commit abe5459c7786d0e09463da5938604212d3ac776c
Showing with 31 additions and 4 deletions.
  1. +17 −4 cloud.sh
  2. +14 −0 info.sh
@@ -1,7 +1,11 @@
#!/usr/bin/php
<?php
declare(strict_types=1);
echo "Loading NEMS state information...";
echo 'Checking if this NEMS server is authorized to use NEMS Cloud... ';
$cloudauth = shell_exec('/usr/local/bin/nems-info cloudauth');
if ($cloudauth == 1) {
echo 'Yes.' . PHP_EOL;
echo 'Loading NEMS state information... ';
$nems = new stdClass();
$nems->state = new stdClass();
$nems->state->raw = trim(shell_exec('/usr/local/bin/nems-info state'));
@@ -34,7 +38,14 @@
}
}
if (isset($nems->state->encrypted) && strlen($nems->state->encrypted) > 0) {
// proceed, but only if the data is encrypted
echo 'Done.' . PHP_EOL;
echo 'Sending data...';
} else {
echo 'Done.' . PHP_EOL;
echo 'Encryption failed, so aborting. Did you activate your NEMS Cloud account?';
}
/**
@@ -109,6 +120,8 @@ function getKeyFromPassword($password, $salt, $keysize = 16)
true
);
}
print_r($nems);
} else {
echo 'No.';
}
echo PHP_EOL;
?>
14 info.sh
@@ -199,6 +199,20 @@ elif [[ $COMMAND == "alias" ]]; then
elif [[ $COMMAND == "state" ]]; then
/usr/local/share/nems/nems-scripts/stats-livestatus-full.sh
elif [[ $COMMAND == "cloudauth" ]]; then
hwid=`/usr/local/bin/nems-info hwid`
osbpass=$(cat /usr/local/share/nems/nems.conf | grep osbpass | printf '%s' $(cut -n -d '=' -f 2))
osbkey=$(cat /usr/local/share/nems/nems.conf | grep osbkey | printf '%s' $(cut -n -d '=' -f 2))
if [[ $osbpass == '' ]] || [[ $osbkey == '' ]]; then
echo NEMS Cloud is not currently enabled.
exit
fi;
data=$(curl -s -F "hwid=$hwid" -F "osbkey=$osbkey" -F "query=status" https://nemslinux.com/api-backend/offsite-backup-checkin.php)
if [[ $data == '1' ]]; then # this account passes authentication
echo 1
else
echo 0
fi
# Output usage info as no valid command line argument was provided
else

0 comments on commit abe5459

Please sign in to comment.