Merge remote-tracking branch 'upstream/main'
This commit is contained in:
@@ -1,176 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Gitea Act Runner Installation Script
|
||||
set -e
|
||||
|
||||
echo "==================================="
|
||||
echo "Gitea Act Runner Installation"
|
||||
echo "==================================="
|
||||
|
||||
# Configuration
|
||||
GITEA_URL="https://gitea.nothaft.cloud"
|
||||
RUNNER_NAME="picpeak-runner-$(hostname)"
|
||||
RUNNER_VERSION="0.2.10" # Latest stable version
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo -e "${YELLOW}This script will help you install and register a Gitea Act Runner${NC}"
|
||||
echo ""
|
||||
|
||||
# Step 1: Get registration token
|
||||
echo -e "${GREEN}Step 1: Get Registration Token${NC}"
|
||||
echo "1. Go to: $GITEA_URL/admin/runners"
|
||||
echo "2. Click 'Create new Runner'"
|
||||
echo "3. Copy the registration token"
|
||||
echo ""
|
||||
read -p "Enter your registration token: " REGISTRATION_TOKEN
|
||||
|
||||
if [ -z "$REGISTRATION_TOKEN" ]; then
|
||||
echo -e "${RED}Error: Registration token is required${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Step 2: Choose installation method
|
||||
echo ""
|
||||
echo -e "${GREEN}Step 2: Choose Installation Method${NC}"
|
||||
echo "1. Docker (Recommended)"
|
||||
echo "2. Binary installation"
|
||||
read -p "Choose method (1 or 2): " METHOD
|
||||
|
||||
if [ "$METHOD" == "1" ]; then
|
||||
# Docker installation
|
||||
echo ""
|
||||
echo -e "${GREEN}Installing with Docker...${NC}"
|
||||
|
||||
# Check if Docker is installed
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo -e "${RED}Error: Docker is not installed${NC}"
|
||||
echo "Please install Docker first: https://docs.docker.com/get-docker/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create docker-compose file for runner
|
||||
cat > docker-compose.runner.yml << EOF
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
gitea-runner:
|
||||
image: gitea/act_runner:latest
|
||||
container_name: gitea-runner
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- GITEA_INSTANCE_URL=$GITEA_URL
|
||||
- GITEA_RUNNER_REGISTRATION_TOKEN=$REGISTRATION_TOKEN
|
||||
- GITEA_RUNNER_NAME=$RUNNER_NAME
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- ./runner-data:/data
|
||||
networks:
|
||||
- picpeak
|
||||
|
||||
networks:
|
||||
picpeak:
|
||||
external: true
|
||||
EOF
|
||||
|
||||
echo "Starting Gitea Runner with Docker..."
|
||||
docker-compose -f docker-compose.runner.yml up -d
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Runner installed and started with Docker${NC}"
|
||||
echo "Check logs with: docker logs gitea-runner"
|
||||
|
||||
elif [ "$METHOD" == "2" ]; then
|
||||
# Binary installation
|
||||
echo ""
|
||||
echo -e "${GREEN}Installing binary...${NC}"
|
||||
|
||||
# Detect OS and architecture
|
||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
ARCH=$(uname -m)
|
||||
|
||||
case "$ARCH" in
|
||||
x86_64)
|
||||
ARCH="amd64"
|
||||
;;
|
||||
aarch64|arm64)
|
||||
ARCH="arm64"
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unsupported architecture: $ARCH${NC}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Download act_runner
|
||||
DOWNLOAD_URL="https://gitea.com/gitea/act_runner/releases/download/v${RUNNER_VERSION}/act_runner-${RUNNER_VERSION}-${OS}-${ARCH}"
|
||||
|
||||
echo "Downloading from: $DOWNLOAD_URL"
|
||||
curl -L -o act_runner "$DOWNLOAD_URL"
|
||||
chmod +x act_runner
|
||||
|
||||
# Create config directory
|
||||
mkdir -p ~/.config/act_runner
|
||||
|
||||
# Register the runner
|
||||
echo ""
|
||||
echo -e "${GREEN}Registering runner...${NC}"
|
||||
./act_runner register \
|
||||
--no-interactive \
|
||||
--instance "$GITEA_URL" \
|
||||
--token "$REGISTRATION_TOKEN" \
|
||||
--name "$RUNNER_NAME" \
|
||||
--labels "ubuntu-latest:docker://node:16-bullseye,ubuntu-22.04:docker://node:16-bullseye,ubuntu-20.04:docker://node:16-bullseye"
|
||||
|
||||
# Create systemd service
|
||||
if [ "$OS" == "linux" ]; then
|
||||
echo ""
|
||||
echo -e "${GREEN}Creating systemd service...${NC}"
|
||||
|
||||
sudo tee /etc/systemd/system/gitea-runner.service > /dev/null << EOF
|
||||
[Unit]
|
||||
Description=Gitea Act Runner
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$USER
|
||||
WorkingDirectory=$PWD
|
||||
ExecStart=$PWD/act_runner daemon
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable gitea-runner
|
||||
sudo systemctl start gitea-runner
|
||||
|
||||
echo -e "${GREEN}✓ Runner installed as systemd service${NC}"
|
||||
echo "Check status with: sudo systemctl status gitea-runner"
|
||||
echo "Check logs with: sudo journalctl -u gitea-runner -f"
|
||||
else
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Runner installed${NC}"
|
||||
echo "Start runner with: ./act_runner daemon"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}==================================="
|
||||
echo "Installation Complete!"
|
||||
echo "===================================${NC}"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo "1. Go to: $GITEA_URL/paul/picpeak/settings/actions/runners"
|
||||
echo "2. Verify your runner appears in the list"
|
||||
echo "3. Push a commit to trigger the test workflow"
|
||||
echo ""
|
||||
echo "If the runner doesn't appear, check the logs for errors."
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
################################################################################
|
||||
# PicPeak Unified Setup Script
|
||||
# Version: 2.0.0
|
||||
# Version: 2.1.0
|
||||
# Description: Universal installer for PicPeak with Docker and Native options
|
||||
# Supports: Ubuntu, Debian, Fedora, RHEL/CentOS, Raspberry Pi OS
|
||||
################################################################################
|
||||
@@ -11,7 +11,7 @@ set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
# Script configuration
|
||||
readonly SCRIPT_VERSION="2.0.0"
|
||||
readonly SCRIPT_VERSION="2.1.0"
|
||||
readonly APP_NAME="PicPeak"
|
||||
readonly REPO_URL="https://github.com/the-luap/picpeak.git"
|
||||
readonly NODE_VERSION="20"
|
||||
@@ -64,17 +64,19 @@ FORCE_ADMIN_PASSWORD_RESET=false
|
||||
# Run a command as the application user, even if sudo is not available
|
||||
run_as_user() {
|
||||
local cmd="$*"
|
||||
local current_dir_escaped
|
||||
current_dir_escaped=$(printf '%q' "$(pwd)")
|
||||
if [[ "$(id -u)" -ne 0 ]]; then
|
||||
# Already non-root; just run
|
||||
bash -lc "$cmd"
|
||||
# Already non-root; preserve working directory
|
||||
bash -lc "cd $current_dir_escaped && $cmd"
|
||||
return $?
|
||||
fi
|
||||
if command_exists sudo; then
|
||||
sudo -H -u "$NATIVE_APP_USER" bash -lc "$cmd"
|
||||
sudo -H -u "$NATIVE_APP_USER" bash -lc "cd $current_dir_escaped && $cmd"
|
||||
elif command_exists runuser; then
|
||||
runuser -u "$NATIVE_APP_USER" -- bash -lc "$cmd"
|
||||
runuser -u "$NATIVE_APP_USER" -- bash -lc "cd $current_dir_escaped && $cmd"
|
||||
else
|
||||
su -s /bin/bash - "$NATIVE_APP_USER" -c "$cmd"
|
||||
su -s /bin/bash - "$NATIVE_APP_USER" -c "cd $current_dir_escaped && $cmd"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -391,7 +393,30 @@ setup_docker_installation() {
|
||||
if [[ -d "$app_dir/.git" ]]; then
|
||||
log_step "Existing PicPeak repository detected; pulling latest changes"
|
||||
cd "$app_dir"
|
||||
git pull --rebase --autostash || git pull
|
||||
git pull
|
||||
elif [[ -d "$app_dir" ]]; then
|
||||
if [[ -z "$(ls -A "$app_dir" 2>/dev/null)" ]]; then
|
||||
log_warn "Existing directory $app_dir is empty but not a git repository; recreating it..."
|
||||
rm -rf "$app_dir"
|
||||
git clone "$REPO_URL" "$app_dir"
|
||||
else
|
||||
log_warn "Directory $app_dir already exists and is not a git repository."
|
||||
if [[ "$UNATTENDED" == "true" ]]; then
|
||||
local backup_dir="${app_dir}.backup-$(date +%Y%m%d-%H%M%S)"
|
||||
log_warn "Unattended mode: backing up directory to $backup_dir and cloning a fresh copy."
|
||||
mv "$app_dir" "$backup_dir"
|
||||
git clone "$REPO_URL" "$app_dir"
|
||||
else
|
||||
if confirm "Replace existing directory $app_dir with a fresh clone? This will move the current contents to a backup folder." "y"; then
|
||||
local backup_dir="${app_dir}.backup-$(date +%Y%m%d-%H%M%S)"
|
||||
mv "$app_dir" "$backup_dir"
|
||||
log_step "Existing directory moved to $backup_dir"
|
||||
git clone "$REPO_URL" "$app_dir"
|
||||
else
|
||||
die "Installation aborted because $app_dir already exists and is not a PicPeak git repository."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [[ -d "$app_dir" && -n "$(find "$app_dir" -mindepth 1 -maxdepth 1 -print -quit 2>/dev/null)" ]]; then
|
||||
die "Target directory $app_dir already exists and is not empty. Remove it or specify --install-dir before retrying."
|
||||
@@ -639,14 +664,17 @@ setup_native_installation() {
|
||||
apt)
|
||||
apt-get install -y build-essential python3
|
||||
;;
|
||||
dnf|yum)
|
||||
if "$PACKAGE_MANAGER" --version 2>/dev/null | grep -Ei 'dnf( |-)5' >/dev/null; then
|
||||
$PACKAGE_MANAGER install -y @development-tools
|
||||
else
|
||||
dnf)
|
||||
if ! $PACKAGE_MANAGER install -y @development-tools; then
|
||||
log_warn "dnf @development-tools group install failed, retrying with legacy groupinstall syntax..."
|
||||
$PACKAGE_MANAGER groupinstall -y "Development Tools"
|
||||
fi
|
||||
$PACKAGE_MANAGER install -y python3
|
||||
;;
|
||||
yum)
|
||||
$PACKAGE_MANAGER groupinstall -y "Development Tools"
|
||||
$PACKAGE_MANAGER install -y python3
|
||||
;;
|
||||
esac
|
||||
|
||||
# Create system user
|
||||
@@ -967,15 +995,17 @@ configure_email() {
|
||||
}
|
||||
|
||||
print_success_message() {
|
||||
local app_dir port
|
||||
local app_dir port manual_reset_hint
|
||||
|
||||
if [[ "$INSTALL_METHOD" == "docker" ]]; then
|
||||
app_dir="$DOCKER_APP_DIR"
|
||||
[[ -n "${SUDO_USER:-}" ]] && app_dir="/home/$SUDO_USER/picpeak"
|
||||
port="${CUSTOM_PORT:-$DEFAULT_PORT}"
|
||||
manual_reset_hint="cd $(printf %q "$app_dir") && docker compose exec -T backend node scripts/reset-admin-password.js --force --credentials-file data/ADMIN_CREDENTIALS.txt"
|
||||
else
|
||||
app_dir="$NATIVE_APP_DIR"
|
||||
port="${CUSTOM_PORT:-$DEFAULT_PORT}"
|
||||
manual_reset_hint="cd $(printf %q "${NATIVE_APP_DIR}/app/backend") && sudo -H -u $(printf %q "$NATIVE_APP_USER") node scripts/reset-admin-password.js --force --credentials-file data/ADMIN_CREDENTIALS.txt"
|
||||
fi
|
||||
|
||||
print_header "🎉 Installation Complete!"
|
||||
@@ -1020,13 +1050,7 @@ print_success_message() {
|
||||
fi
|
||||
else
|
||||
echo -e "Email: ${CYAN}$ADMIN_EMAIL${NC}"
|
||||
local reset_hint
|
||||
if [[ "$INSTALL_METHOD" == "docker" ]]; then
|
||||
reset_hint="docker compose exec backend node scripts/reset-admin-password.js"
|
||||
else
|
||||
reset_hint="cd $NATIVE_APP_DIR/app/backend && node scripts/reset-admin-password.js"
|
||||
fi
|
||||
echo -e "Password: ${YELLOW}(credentials file not found - rerun setup with --force-admin-password-reset or run $reset_hint)${NC}"
|
||||
echo -e "Password: ${YELLOW}(credentials file not found - rerun setup with --force-admin-password-reset or run '${manual_reset_hint}')${NC}"
|
||||
fi
|
||||
echo
|
||||
echo -e "${YELLOW}⚠️ IMPORTANT: Change the admin password on first login!${NC}"
|
||||
Reference in New Issue
Block a user