diff options
-rw-r--r-- | changelog.md | 6 | ||||
-rw-r--r-- | ncp-activation/CSS.css | 242 | ||||
-rw-r--r-- | ncp-activation/JS.js | 124 | ||||
-rw-r--r-- | ncp-activation/index.php | 67 | ||||
-rw-r--r-- | ncp.sh | 2 | ||||
-rw-r--r-- | updates/1.40.0.sh | 36 |
6 files changed, 474 insertions, 3 deletions
diff --git a/changelog.md b/changelog.md index dc928e65..9255f50b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,9 @@ -[v1.39.1](https://github.com/nextcloud/nextcloudpi/commit/79ee5c5) (2021-09-09) nc-static-IP: take into account httpsonly +[v1.39.2](https://github.com/nextcloud/nextcloudpi/commit/9598430) (2021-09-18) nextcloud-domain: make sure redis is running before it starts -[v1.39.0 ](https://github.com/nextcloud/nextcloudpi/commit/3ef774c) (2021-09-05) upgrade to NC21.0.4 +[v1.39.1 ](https://github.com/nextcloud/nextcloudpi/commit/6290c1f) (2021-09-09) nc-static-IP: take into account httpsonly + +[v1.39.0 ](https://github.com/nextcloud/nextcloudpi/commit/c10d4bd) (2021-09-05) upgrade to NC21.0.4 [v1.38.6](https://github.com/nextcloud/nextcloudpi/commit/3bf746b) (2021-08-25) raspi: allow oldstable origins diff --git a/ncp-activation/CSS.css b/ncp-activation/CSS.css new file mode 100644 index 00000000..2cb5638e --- /dev/null +++ b/ncp-activation/CSS.css @@ -0,0 +1,242 @@ +/* + * NextCloudPi Web Panel style sheets. Based on official Nextcloud 12 datasheets + * + * 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! + * + * More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/ +*/ + + +html,body { + height:100% +} +article,aside,dialog,figure,footer,header,hgroup,nav,section { + display:block +} +body { + text-align: center; + line-height:1.5 +} +a { + border:0; + color:#fff; + text-decoration:none; + cursor:pointer +} +a * { + cursor:pointer +} +select,.button span,label { + cursor:pointer +} +body { + background-image: url(../img/background.png); + background-color:#0082c9; + font-weight:400; + line-height:1.6em; + font-family:'Open Sans', Frutiger, Calibri, 'Myriad Pro', Myriad, sans-serif; + color:#fff; + height:auto +} +#nojavascript { + position:fixed; + top:0; + bottom:0; + height:100%; + width:100%; + z-index:9000; + text-align:center; + background-color:rgba(0, 0, 0, 0.5); + color:#fff; + line-height:125%; + font-size:24px +} +#nojavascript div { + display:block; + position:relative; + width:50%; + top:35%; + margin:0px auto +} +#nojavascript a { + color:#fff; + border-bottom:2px dotted #fff +} +#nojavascript a:hover,#nojavascript a:focus { + color:#dbdbdb +} +::-webkit-scrollbar { + width:5px +} +::-webkit-scrollbar-track-piece { + background-color:transparent +} +::-webkit-scrollbar-thumb { + background:#dbdbdb; + border-radius:3px +} +select,button,input,textarea { + width: 3em; + min-height:32px; + box-sizing:border-box; + text-align: center; +} +select,button,.button,input:not([type='range']),textarea,#quota,.pager li a { + margin:3px 3px 3px 0; + padding:7px 6px; + font-size:13px; + background-color:#fff; + color:#545454; + border:1px solid #dbdbdb; + outline:none; + border-radius:3px; +} +select:not(:disabled):not(.primary),button:not(:disabled):not(.primary),.button:not(:disabled):not(.primary),input:not([type='range']):not(:disabled):not(.primary),textarea:not(:disabled):not(.primary),#quota:not(:disabled):not(.primary),.pager li a:not(:disabled):not(.primary) { +} +select:not(:disabled):not(.primary):not(#quota):hover,button:not(:disabled):not(.primary):not(#quota):hover,.button:not(:disabled):not(.primary):not(#quota):hover,input:not([type='range']):not(:disabled):not(.primary):not(#quota):hover,textarea:not(:disabled):not(.primary):not(#quota):hover,#quota:not(:disabled):not(.primary):not(#quota):hover,.pager li a:not(:disabled):not(.primary):not(#quota):hover,select:not(:disabled):not(.primary):focus,button:not(:disabled):not(.primary):focus,.button:not(:disabled):not(.primary):focus,input:not([type='range']):not(:disabled):not(.primary):focus,textarea:not(:disabled):not(.primary):focus,#quota:not(:disabled):not(.primary):focus,.pager li a:not(:disabled):not(.primary):focus,select:not(:disabled):not(.primary).active,button:not(:disabled):not(.primary).active,.button:not(:disabled):not(.primary).active,input:not([type='range']):not(:disabled):not(.primary).active,textarea:not(:disabled):not(.primary).active,#quota:not(:disabled):not(.primary).active,.pager li a:not(:disabled):not(.primary).active { + border-color:#0082c9; + outline:none +} +select:not(:disabled):not(.primary):active,button:not(:disabled):not(.primary):active,.button:not(:disabled):not(.primary):active,input:not([type='range']):not(:disabled):not(.primary):active,textarea:not(:disabled):not(.primary):active,#quota:not(:disabled):not(.primary):active,.pager li a:not(:disabled):not(.primary):active { + outline:none; + background-color:#fff +} +select:disabled,button:disabled,.button:disabled,input:not([type='range']):disabled,textarea:disabled,#quota:disabled,.pager li a:disabled { + background-color:#ebebeb; + color:rgba(0, 0, 0, 0.4); + cursor:default; + opacity:0.5 +} +select.primary,button.primary,.button.primary,input:not([type='range']).primary,textarea.primary,#quota.primary,.pager li a.primary { + border:1px solid #0082c9; + background-color:rgba(0, 130, 201, .7); + color:#fff; + cursor:pointer +} +select.primary:not(:disabled):hover,button.primary:not(:disabled):hover,.button.primary:not(:disabled):hover,input:not([type='range']).primary:not(:disabled):hover,textarea.primary:not(:disabled):hover,#quota.primary:not(:disabled):hover,.pager li a.primary:not(:disabled):hover,select.primary:not(:disabled):focus,button.primary:not(:disabled):focus,.button.primary:not(:disabled):focus,input:not([type='range']).primary:not(:disabled):focus,textarea.primary:not(:disabled):focus,#quota.primary:not(:disabled):focus,.pager li a.primary:not(:disabled):focus { + background-color:rgba(0, 130, 201, .85) +} +select.primary:not(:disabled):active,button.primary:not(:disabled):active,.button.primary:not(:disabled):active,input:not([type='range']).primary:not(:disabled):active,textarea.primary:not(:disabled):active,#quota.primary:not(:disabled):active,.pager li a.primary:not(:disabled):active { + background-color:rgba(0, 130, 201, .7) +} +select.primary:disabled,button.primary:disabled,.button.primary:disabled,input:not([type='range']).primary:disabled,textarea.primary:disabled,#quota.primary:disabled,.pager li a.primary:disabled { + background-color:rgba(0, 130, 201, .7); + color:#bababa +} +input { +} +input:not([type='radio']):not([type='checkbox']):not([type='range']):not([type='submit']):not([type='button']):not([type='reset']):not([type='color']):not([type='file']):not([type='image']) { + -webkit-appearance:textfield; + -moz-appearance:textfield +} +select,button,.button,input[type='button'],input[type='submit'],input[type='reset'] { + padding:6px 12px; + width:auto; + min-height:34px; + cursor:pointer; + box-sizing:border-box; + background-color:#f7f7f7 +} +button,.button,input[type='button'],input[type='submit'],input[type='reset'] { + font-weight:bold; +} +button::-moz-focus-inner,.button::-moz-focus-inner,input[type='button']::-moz-focus-inner,input[type='submit']::-moz-focus-inner,input[type='reset']::-moz-focus-inner { + border:0 +} +button,.button { +} +button > span[class^='icon-'],.button > span[class^='icon-'],button > span[class*=' icon-'],.button > span[class*=' icon-'] { + display:inline-block; + vertical-align:text-bottom; + opacity:0.5 +} +textarea { + color:#545454; + cursor:text; + font-family:inherit; + height:auto +} +textarea:not(:disabled):active,textarea:not(:disabled):hover,textarea:not(:disabled):focus { + border-color:#dbdbdb !important; + background-color:#fff !important +} +select { + -webkit-appearance:none; + -moz-appearance:none; + appearance:none; + background:url('../../../core/css/../img/actions/triangle-s.svg') no-repeat right 4px center; + background-color:inherit; + outline:0; + padding-right:24px !important +} +button img,.button img { + cursor:pointer +} +input[type='checkbox'].radio,input[type='radio'].radio,input[type='checkbox'].checkbox,input[type='radio'].checkbox { + position:absolute; + left:-10000px; + top:auto; + width:1px; + height:1px; + overflow:hidden +} +#header { + color: white; +} +h2 { + font-size:20px; + font-weight:300; + margin-bottom:12px; + line-height:140% +} +h3 { + font-size:15px; + font-weight:300; + margin:12px 0 +} +em { + font-style:normal; + -ms-filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)'; + opacity:0.5 +} +dl { + padding:12px 0 +} +dt,dd { + display:inline-block; + padding:12px; + padding-left:0 +} +dt { + width:130px; + white-space:nowrap; + text-align:right +} +kbd { + padding:4px 10px; + border:1px solid #ccc; + box-shadow:0 1px 0 rgba(0, 0, 0, .2); + border-radius:3px; + display:inline-block; + white-space:nowrap +} + +hr { border: solid 1px white; } + +#ncp-logo { margin-top: 24px; } + +#loading-gif { display: none; } + +#ncp-pwd,#nc-pwd{ width:30em; } + +img { vertical-align: middle; } + +.info { + text-shadow: 0 0 2px rgba(0, 0, 0, .4); + font-size: 80%; +} + +.info a { + font-weight: 600; +} diff --git a/ncp-activation/JS.js b/ncp-activation/JS.js new file mode 100644 index 00000000..3432dbe1 --- /dev/null +++ b/ncp-activation/JS.js @@ -0,0 +1,124 @@ +/// +// NextCloudPi Web Panel javascript library +// +// Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com> +// GPL licensed (see end of file) * Use at your own risk! +// +// More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/ +/// + +var MINI = require('minified'); +var $ = MINI.$, $$ = MINI.$$, EE = MINI.EE; +var selectedID = null; +var confLock = false; + +function errorMsg() +{ + $('#error-box').fill( "Something went wrong. Try refreshing the page" ); +} + +function launch_nc_passwd() +{ + // request + $.request('post', '../ncp-launcher.php', { action: 'launch', + ref : 'nc-passwd', + config: '{ "PASSWORD":"' + $('#ncp-pwd').get('.value') + '",' + + '"CONFIRM" :"' + $('#ncp-pwd').get('.value') + '"}', + csrf_token: $( '#csrf-token' ).get( '.value' ) }).then( + + function success( result ) + { + var ret = $.parseJSON( result ); + if ( ret.ret == '0' ) + { + setTimeout( function(){ + $('#loading-gif').hide(); + $('#error-box').fill( "ACTIVATION SUCCESSFUL" ); + var url = window.location.protocol + '//' + window.location.hostname + ':4443'; + if ( !window.open( url, '_blank' ) ) // try to open in a new tab first + window.location.replace( url ); + }, 4000 ); + } else { + $('#error-box').fill( "nc-passwd error" ); + } + } ).error( errorMsg ); +} + +function nc_admin_ok_cb( result ) +{ + var ret = $.parseJSON( result ); + if ( ret.token ) + $('#csrf-token').set( { value: ret.token } ); + if ( ret.ret == '0' ) { + launch_nc_passwd(); + } else { + $('#error-box').fill( "NextCloudPi not yet initialized, trying again in a few seconds ..." ); + setTimeout( launch_activation, 10000 ); + } +} + +function launch_activation() +{ + // request + $.request('post', '../ncp-launcher.php', { action: 'launch', + ref : 'nc-admin', + config: '{ "PASSWORD":"' + $('#nc-pwd').get('.value') + '",' + + '"CONFIRM" :"' + $('#nc-pwd').get('.value') + '",' + + '"USER" : "ncp" }', + csrf_token: $( '#csrf-token' ).get( '.value' ) } + ).then( nc_admin_ok_cb ).error( errorMsg ); +} + +$(function() +{ + // print info page + $( '#print-pwd' ).on( 'click', function(e) { window.print(); } ); + + // copy to clipboard + $( '#cp-ncp' ).on( 'click', function(e) + { + var input = document.getElementById('ncp-pwd'); + input.focus(); + input.select(); + var res =document.execCommand( 'copy' ); + $('#cp-ncp-ok').fill( res ? "✓" : "✘" ); + input.selectionStart = input.selectionEnd; + } ); + + // copy to clipboard + $( '#cp-nc' ).on( 'click', function(e) + { + var input = document.getElementById('nc-pwd'); + input.focus(); + input.select(); + var res =document.execCommand( 'copy' ); + $('#cp-nc-ok').fill( res ? "✓" : "✘" ); + input.selectionStart = input.selectionEnd; + } ); + + // activate NextCloudPi + $( '#activate-ncp' ).on( 'click', function(e) + { + $( '#activate-ncp' ).hide(); + $( '#print-pwd' ).hide(); + $('#loading-gif').set( { $display: 'inline' } ); + launch_activation(); + } ); +} ); + +// License +// +// This script is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This script is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this script; if not, write to the +// Free Software Foundation, Inc., 59 Temple Place, Suite 330, +// Boston, MA 02111-1307 USA diff --git a/ncp-activation/index.php b/ncp-activation/index.php new file mode 100644 index 00000000..8b2d901c --- /dev/null +++ b/ncp-activation/index.php @@ -0,0 +1,67 @@ +<?php session_start(); ?> +<!DOCTYPE html> +<html class="ng-csp" data-placeholder-focus="false" lang="en"> +<head> + <meta http-equiv="content-type" content="text/html; charset=UTF-8"> + <meta charset="utf-8"> + <title> NextCloudPi Activation </title> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="referrer" content="never"> + <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"> + <meta http-equiv="cache-control" content="no-cache"> + <meta http-equiv="pragma" content="no-cache"> + <link rel="icon" type="image/png" href="img/favicon.png"/> + <link rel="stylesheet" href="CSS.css"> +</head> +<body id="body-login"> + <noscript> + <div id="nojavascript"> + <div> + This application requires JavaScript for correct operation. Please <a href="https://www.enable-javascript.com/" target="_blank" rel="noreferrer noopener">enable JavaScript</a> and reload the page. </div> + </div> + </noscript> + <div class="wrapper"> + <div class="v-align"> + <header role="banner"> + <div id="header"> + <img id="ncp-logo" src="../img/ncp-logo.svg"> +<?php + $nc_pwd = rtrim( base64_encode( random_bytes(32) ) , '=' ); // remove last '='. Remove rtrim in the future + $ncp_pwd = rtrim( base64_encode( random_bytes(32) ) , '=' ); // remove last '='. Remove rtrim in the future + echo <<<HTML + <h1>NextCloudPi Activation</h1> + <p>Your NextCloudPi user is </p><input readonly type="text" size=32 value="ncp"> + <p>Your NextCloudPi password is </p><input readonly id="ncp-pwd" type="text" size=32 value="{$ncp_pwd}"> <img id="cp-ncp" src="../img/clippy.svg"><span id="cp-ncp-ok"></span> + <p>Save this password in order to access to the NextCloudPi web interface at https://nextcloudpi.local:4443</p> + <p>This password can be changed using 'nc-passwd'</p> +<hr> + <p>Your NextCloud user is </p><input readonly type="text" size=32 value="ncp"> + <p>Your Nextcloud password is </p><input readonly id="nc-pwd" type="text" size=32 value="{$nc_pwd}"> <img id="cp-nc" src="../img/clippy.svg"><span id="cp-nc-ok"></span> + <p>Save this password in order to access NextCloud https://nextcloudpi.local</p> + <p>This password can be changed from the Nextcloud user configuration</p> +<br> + <p> + <button type="button" id="print-pwd" > Print </button> + <button type="button" id="activate-ncp"> Activate </button> + </p> +<br> + <img id="loading-gif" src="../img/loading-small.gif"> + <div id="error-box"></div> +HTML; +?> + </div> + </header> + </div> + </div> + <footer role="contentinfo"> + <p class="info"> + <a href="https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/" target="_blank" rel="noreferrer noopener">NextCloudPi</a> – Keep your data close</p> + </footer> + <?php + include('../csrf.php'); + echo '<input type="hidden" id="csrf-token" name="csrf-token" value="' . getCSRFToken() . '"/>'; + ?> + <script src="../js/minified.js"></script> + <script src="JS.js"></script> +</body> +</html> @@ -177,7 +177,7 @@ EOF [Unit] Description=Register Current IP as Nextcloud trusted domain Requires=network.target -After=mysql.service +After=mysql.service redis.service [Service] ExecStart=/bin/bash /usr/local/bin/nextcloud-domain.sh diff --git a/updates/1.40.0.sh b/updates/1.40.0.sh new file mode 100644 index 00000000..43f56cc3 --- /dev/null +++ b/updates/1.40.0.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -e + +## BACKWARD FIXES ( for older images ) + +source /usr/local/etc/library.sh # sets NCLATESTVER PHPVER RELEASE + +# all images + +# docker images only +[[ -f /.docker-image ]] && { + : +} + +# for non docker images +[[ ! -f /.docker-image ]] && { + + # make sure redis is up before running nextclud-domain + cat > /usr/lib/systemd/system/nextcloud-domain.service <<'EOF' +[Unit] +Description=Register Current IP as Nextcloud trusted domain +Requires=network.target +After=mysql.service redis.service + +[Service] +ExecStart=/bin/bash /usr/local/bin/nextcloud-domain.sh +Restart=on-failure +RestartSec=5s + +[Install] +WantedBy=multi-user.target +EOF +} + +exit 0 |