mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 22:27:01 +01:00
Two levels of pure taxonomy carrying no information, and a 2-directory
cap leaves no room for them. Categories now sit directly under
linux_configuration/: features, fixes, utils, misc, fresh-install,
installers, diagnostics, gaming, boot_recovery, periodic_background, lib,
meta, tests. A script's own lib/ and tests/ are exempt from the cap, so
those stay put.
Depth violations 248 -> 139; roughly 40 of the remainder are inside
digital_wellbeing and hosts, deferred until the guard-lib repoint.
The moves are the easy half. What breaks is every path that counted
levels, and three classes of it had to be found by resolving paths rather
than reading diffs:
- 52 relative `source` lines for lib/common.sh and lib/android.sh. The
correct prefix differs per file: 40 were ../../ and 12 were ../../../,
so a blanket replace would have fixed one set and broken the other.
- REPO_ROOT in 7 fixes/lib/tests harnesses and setup_syncyomi_guard.sh,
each walking up four levels from a directory now two levels shallower.
This caused a real regression -- the fixes suite went red with
"log_warn: command not found" -- caught by running it and comparing
against the pre-move baseline worktree.
- conftest.py's sys.path entries, which took the pytest gate down with
14 collection errors, and the `# shellcheck source=` directives, which
took shellcheck down with SC1091.
16 symlinks in $HOME broke, including the entire i3blocks bar. All
repointed, and cpu_monitor/memory/disk/time/volume were run to confirm
they emit real output rather than merely resolving.
Verified: 1798 tests pass at 100% coverage, 8 of 9 lib/tests suites pass
(the ninth needs the coverage jail, identically at baseline), pre-commit
is clean, and the two untracked secret configs are still ignored after
their gitignore paths changed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
164 lines
4.0 KiB
Bash
Executable File
164 lines
4.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Nextcloud Installation Script for Raspberry Pi
|
|
# This script installs and configures Nextcloud on a Raspberry Pi
|
|
#
|
|
# Usage:
|
|
# ./raspberry_pi_nextcloud.sh install - Install Nextcloud (run on Pi or via SSH)
|
|
# ./raspberry_pi_nextcloud.sh fix - Fix common Nextcloud issues
|
|
# ./raspberry_pi_nextcloud.sh install-remote - Install Nextcloud via SSH from laptop
|
|
|
|
set -euo pipefail
|
|
|
|
# Script directory for config file
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
CONFIG_FILE="${SCRIPT_DIR}/.raspberry_pi.conf"
|
|
|
|
# Load configuration from gitignored config file if it exists
|
|
if [[ -f $CONFIG_FILE ]]; then
|
|
# shellcheck source=/dev/null
|
|
source "$CONFIG_FILE"
|
|
fi
|
|
|
|
# Configuration
|
|
PI_HOSTNAME="${PI_HOSTNAME:-nextcloud-pi}"
|
|
PI_USER="${PI_USER:-pi}"
|
|
PI_PASSWORD="${PI_PASSWORD:-}"
|
|
PI_TIMEZONE="${PI_TIMEZONE:-Europe/Warsaw}"
|
|
PI_LOCALE="${PI_LOCALE:-en_US.UTF-8}"
|
|
NEXTCLOUD_ADMIN_USER="${NEXTCLOUD_ADMIN_USER:-admin}"
|
|
NEXTCLOUD_ADMIN_PASSWORD="${NEXTCLOUD_ADMIN_PASSWORD:-}"
|
|
NEXTCLOUD_DATA_DIR="${NEXTCLOUD_DATA_DIR:-/var/www/nextcloud/data}"
|
|
NEXTCLOUD_VERSION="${NEXTCLOUD_VERSION:-latest}"
|
|
|
|
# DuckDNS for free domain and Let's Encrypt SSL
|
|
# Get your free subdomain at https://www.duckdns.org/
|
|
DUCKDNS_DOMAIN="${DUCKDNS_DOMAIN:-}" # e.g., "mycloud" for mycloud.duckdns.org
|
|
DUCKDNS_TOKEN="${DUCKDNS_TOKEN:-}" # Your DuckDNS token
|
|
LETSENCRYPT_EMAIL="${LETSENCRYPT_EMAIL:-}" # Email for Let's Encrypt notifications
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log_info() {
|
|
echo -e "${BLUE}[INFO]${NC} $1" >&2
|
|
}
|
|
|
|
log_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1" >&2
|
|
}
|
|
|
|
log_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1" >&2
|
|
}
|
|
|
|
log_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1" >&2
|
|
}
|
|
|
|
die() {
|
|
log_error "$1"
|
|
exit 1
|
|
}
|
|
|
|
check_root() {
|
|
if [[ $EUID -ne 0 ]]; then
|
|
die "This script must be run as root. Use: sudo $0"
|
|
fi
|
|
}
|
|
|
|
save_config() {
|
|
cat >"$CONFIG_FILE" <<EOF
|
|
# Raspberry Pi Nextcloud Setup - Auto-generated config
|
|
# This file is gitignored and stores discovered settings
|
|
|
|
# Pi configuration
|
|
PI_HOSTNAME="${PI_HOSTNAME}"
|
|
PI_USER="${PI_USER}"
|
|
PI_TIMEZONE="${PI_TIMEZONE}"
|
|
NEXTCLOUD_ADMIN_USER="${NEXTCLOUD_ADMIN_USER}"
|
|
|
|
# Generated passwords (KEEP THIS FILE SECURE!)
|
|
PI_PASSWORD="${PI_PASSWORD}"
|
|
NEXTCLOUD_ADMIN_PASSWORD="${NEXTCLOUD_ADMIN_PASSWORD}"
|
|
|
|
# DuckDNS for Let's Encrypt SSL (optional)
|
|
DUCKDNS_DOMAIN="${DUCKDNS_DOMAIN:-}"
|
|
DUCKDNS_TOKEN="${DUCKDNS_TOKEN:-}"
|
|
LETSENCRYPT_EMAIL="${LETSENCRYPT_EMAIL:-}"
|
|
EOF
|
|
chmod 600 "$CONFIG_FILE"
|
|
log_info "Configuration saved to $CONFIG_FILE"
|
|
}
|
|
|
|
generate_password() {
|
|
local length="${1:-16}"
|
|
local chars
|
|
chars=$(dd if=/dev/urandom bs=256 count=1 2>/dev/null | tr -dc 'A-Za-z0-9!@#$%&*' | cut -c1-"$length")
|
|
echo "$chars"
|
|
}
|
|
|
|
auto_generate_nextcloud_password() {
|
|
if [[ -z $NEXTCLOUD_ADMIN_PASSWORD ]]; then
|
|
NEXTCLOUD_ADMIN_PASSWORD=$(generate_password 20)
|
|
log_info "Auto-generated Nextcloud admin password (will be saved to config file)"
|
|
fi
|
|
}
|
|
|
|
# shellcheck source=lib/rpi_nc_deps.sh
|
|
source "$SCRIPT_DIR/lib/rpi_nc_deps.sh"
|
|
# shellcheck source=lib/rpi_nc_system.sh
|
|
source "$SCRIPT_DIR/lib/rpi_nc_system.sh"
|
|
# shellcheck source=lib/rpi_nc_install.sh
|
|
source "$SCRIPT_DIR/lib/rpi_nc_install.sh"
|
|
# shellcheck source=lib/rpi_nc_fixes.sh
|
|
source "$SCRIPT_DIR/lib/rpi_nc_fixes.sh"
|
|
# shellcheck source=lib/rpi_nc_ssl.sh
|
|
source "$SCRIPT_DIR/lib/rpi_nc_ssl.sh"
|
|
# shellcheck source=lib/rpi_nc_ssl_remote.sh
|
|
source "$SCRIPT_DIR/lib/rpi_nc_ssl_remote.sh"
|
|
# shellcheck source=lib/rpi_nc_ca.sh
|
|
source "$SCRIPT_DIR/lib/rpi_nc_ca.sh"
|
|
|
|
|
|
main() {
|
|
local command="${1:-help}"
|
|
|
|
case "$command" in
|
|
install-remote)
|
|
phase_install_remote
|
|
;;
|
|
setup-ssl-remote)
|
|
phase_setup_ssl_remote
|
|
;;
|
|
setup-ssl)
|
|
phase_setup_ssl
|
|
;;
|
|
install-ca)
|
|
phase_install_ca
|
|
;;
|
|
configure)
|
|
phase_configure_system
|
|
;;
|
|
install-local | install)
|
|
phase_install_nextcloud
|
|
;;
|
|
fix)
|
|
phase_fix_issues
|
|
;;
|
|
help | --help | -h)
|
|
show_help
|
|
;;
|
|
*)
|
|
log_error "Unknown command: $command"
|
|
show_help
|
|
exit 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
main "$@"
|