Update builder
This commit is contained in:
25
packaging/DEBIAN/postrm
Executable file
25
packaging/DEBIAN/postrm
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Post-removal script for adastra-storage
|
||||
|
||||
INSTALL_DIR="/opt/adastra-storage"
|
||||
SERVICE_USER="adastra"
|
||||
|
||||
echo "Adastra Storage: Post-removal cleanup..."
|
||||
|
||||
# Remove service user (optional - comment out if you want to keep the user)
|
||||
# if id "$SERVICE_USER" &>/dev/null; then
|
||||
# echo "Removing service user: $SERVICE_USER"
|
||||
# userdel "$SERVICE_USER" || true
|
||||
# fi
|
||||
|
||||
# Note: We don't remove /opt/adastra-storage by default
|
||||
# to preserve data. Use the uninstaller script for complete removal.
|
||||
|
||||
echo "Adastra Storage removal complete!"
|
||||
echo "Note: Data directory at $INSTALL_DIR/data has been preserved."
|
||||
echo "To completely remove, run: $INSTALL_DIR/uninstall.sh"
|
||||
|
||||
exit 0
|
||||
|
||||
22
packaging/DEBIAN/prerm
Executable file
22
packaging/DEBIAN/prerm
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Pre-removal script for adastra-storage
|
||||
|
||||
echo "Adastra Storage: Pre-removal cleanup..."
|
||||
|
||||
# Stop and disable service
|
||||
if systemctl is-active adastra-storage.service >/dev/null 2>&1; then
|
||||
echo "Stopping adastra-storage service..."
|
||||
systemctl stop adastra-storage.service
|
||||
fi
|
||||
|
||||
if systemctl is-enabled adastra-storage.service >/dev/null 2>&1; then
|
||||
echo "Disabling adastra-storage service..."
|
||||
systemctl disable adastra-storage.service
|
||||
fi
|
||||
|
||||
systemctl daemon-reload
|
||||
|
||||
exit 0
|
||||
|
||||
77
packaging/INSTALL.md
Normal file
77
packaging/INSTALL.md
Normal file
@@ -0,0 +1,77 @@
|
||||
# Installation Guide
|
||||
|
||||
## Quick Installation
|
||||
|
||||
### Using the Installation Script
|
||||
|
||||
```bash
|
||||
sudo bash packaging/install.sh
|
||||
sudo systemctl start adastra-storage
|
||||
sudo systemctl enable adastra-storage
|
||||
```
|
||||
|
||||
### Using Debian Package
|
||||
|
||||
```bash
|
||||
cd packaging
|
||||
sudo ./build-deb.sh
|
||||
sudo dpkg -i ../adastra-storage_1.0.0_amd64.deb
|
||||
sudo apt-get install -f
|
||||
sudo systemctl start adastra-storage
|
||||
```
|
||||
|
||||
## Post-Installation
|
||||
|
||||
1. Access the web interface: http://localhost:8080
|
||||
2. Login with default credentials:
|
||||
- Username: `admin`
|
||||
- Password: `admin`
|
||||
3. **IMPORTANT**: Change the default password immediately!
|
||||
|
||||
## Service Management
|
||||
|
||||
```bash
|
||||
# Start
|
||||
sudo systemctl start adastra-storage
|
||||
|
||||
# Stop
|
||||
sudo systemctl stop adastra-storage
|
||||
|
||||
# Restart
|
||||
sudo systemctl restart adastra-storage
|
||||
|
||||
# Status
|
||||
sudo systemctl status adastra-storage
|
||||
|
||||
# Logs
|
||||
sudo journalctl -u adastra-storage -f
|
||||
```
|
||||
|
||||
## Uninstallation
|
||||
|
||||
```bash
|
||||
sudo /opt/adastra-storage/uninstall.sh
|
||||
```
|
||||
|
||||
## File Locations
|
||||
|
||||
- Installation: `/opt/adastra-storage`
|
||||
- Database: `/opt/adastra-storage/data/appliance.db`
|
||||
- Service file: `/etc/systemd/system/adastra-storage.service`
|
||||
- Logs: `journalctl -u adastra-storage`
|
||||
|
||||
## Dependencies
|
||||
|
||||
The installer automatically installs:
|
||||
- golang-go
|
||||
- zfsutils-linux
|
||||
- smartmontools
|
||||
- nfs-kernel-server
|
||||
- samba
|
||||
- targetcli-fb
|
||||
- minio
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
See the main README.md for detailed troubleshooting information.
|
||||
|
||||
37
packaging/adastra-storage.service
Normal file
37
packaging/adastra-storage.service
Normal file
@@ -0,0 +1,37 @@
|
||||
[Unit]
|
||||
Description=Adastra Storage Appliance Management System
|
||||
Documentation=https://github.com/example/storage-appliance
|
||||
After=network.target zfs-import.service
|
||||
Wants=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=adastra
|
||||
Group=adastra
|
||||
WorkingDirectory=/opt/adastra-storage
|
||||
ExecStart=/opt/adastra-storage/bin/adastra-storage
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=adastra-storage
|
||||
|
||||
# Security settings
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
ProtectSystem=strict
|
||||
ProtectHome=true
|
||||
ReadWritePaths=/opt/adastra-storage/data /opt/adastra-storage/logs
|
||||
|
||||
# Resource limits
|
||||
LimitNOFILE=65536
|
||||
LimitNPROC=4096
|
||||
|
||||
# Environment
|
||||
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
Environment="INSTALL_DIR=/opt/adastra-storage"
|
||||
Environment="DATA_DIR=/opt/adastra-storage/data"
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
70
packaging/build-deb.sh
Executable file
70
packaging/build-deb.sh
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Build Debian package script
|
||||
|
||||
VERSION="1.0.0"
|
||||
PACKAGE_NAME="adastra-storage"
|
||||
BUILD_DIR="$(pwd)"
|
||||
PACKAGE_DIR="$BUILD_DIR/packaging"
|
||||
DEB_DIR="$BUILD_DIR/deb-build"
|
||||
ARCH="amd64"
|
||||
|
||||
echo "Building Debian package for $PACKAGE_NAME version $VERSION"
|
||||
|
||||
# Clean previous build
|
||||
rm -rf "$DEB_DIR"
|
||||
|
||||
# Create package structure
|
||||
mkdir -p "$DEB_DIR/$PACKAGE_NAME/DEBIAN"
|
||||
mkdir -p "$DEB_DIR/$PACKAGE_NAME/opt/adastra-storage/bin"
|
||||
mkdir -p "$DEB_DIR/$PACKAGE_NAME/opt/adastra-storage/templates"
|
||||
mkdir -p "$DEB_DIR/$PACKAGE_NAME/opt/adastra-storage/migrations"
|
||||
mkdir -p "$DEB_DIR/$PACKAGE_NAME/opt/adastra-storage/data"
|
||||
mkdir -p "$DEB_DIR/$PACKAGE_NAME/etc/systemd/system"
|
||||
|
||||
# Copy control files
|
||||
cp "$PACKAGE_DIR/DEBIAN/control" "$DEB_DIR/$PACKAGE_NAME/DEBIAN/"
|
||||
cp "$PACKAGE_DIR/DEBIAN/postinst" "$DEB_DIR/$PACKAGE_NAME/DEBIAN/"
|
||||
cp "$PACKAGE_DIR/DEBIAN/prerm" "$DEB_DIR/$PACKAGE_NAME/DEBIAN/"
|
||||
cp "$PACKAGE_DIR/DEBIAN/postrm" "$DEB_DIR/$PACKAGE_NAME/DEBIAN/"
|
||||
chmod +x "$DEB_DIR/$PACKAGE_NAME/DEBIAN/postinst"
|
||||
chmod +x "$DEB_DIR/$PACKAGE_NAME/DEBIAN/prerm"
|
||||
chmod +x "$DEB_DIR/$PACKAGE_NAME/DEBIAN/postrm"
|
||||
|
||||
# Build the application
|
||||
echo "Building application binary..."
|
||||
cd "$BUILD_DIR"
|
||||
go build -o "$DEB_DIR/$PACKAGE_NAME/opt/adastra-storage/bin/adastra-storage" ./cmd/appliance
|
||||
|
||||
# Copy application files
|
||||
echo "Copying application files..."
|
||||
cp -r "$BUILD_DIR/internal/templates"/* "$DEB_DIR/$PACKAGE_NAME/opt/adastra-storage/templates/"
|
||||
cp -r "$BUILD_DIR/migrations"/* "$DEB_DIR/$PACKAGE_NAME/opt/adastra-storage/migrations/"
|
||||
cp "$PACKAGE_DIR/uninstall.sh" "$DEB_DIR/$PACKAGE_NAME/opt/adastra-storage/uninstall.sh"
|
||||
chmod +x "$DEB_DIR/$PACKAGE_NAME/opt/adastra-storage/uninstall.sh"
|
||||
|
||||
# Copy systemd service
|
||||
cp "$PACKAGE_DIR/adastra-storage.service" "$DEB_DIR/$PACKAGE_NAME/etc/systemd/system/"
|
||||
|
||||
# Set permissions
|
||||
chmod 755 "$DEB_DIR/$PACKAGE_NAME/opt/adastra-storage/bin/adastra-storage"
|
||||
chmod 755 "$DEB_DIR/$PACKAGE_NAME/opt/adastra-storage/data"
|
||||
|
||||
# Build the package
|
||||
echo "Building .deb package..."
|
||||
cd "$DEB_DIR"
|
||||
dpkg-deb --build "$PACKAGE_NAME" "${PACKAGE_NAME}_${VERSION}_${ARCH}.deb"
|
||||
|
||||
# Move to build directory
|
||||
mv "${PACKAGE_NAME}_${VERSION}_${ARCH}.deb" "$BUILD_DIR/"
|
||||
|
||||
echo ""
|
||||
echo "Package built successfully:"
|
||||
echo " $BUILD_DIR/${PACKAGE_NAME}_${VERSION}_${ARCH}.deb"
|
||||
echo ""
|
||||
echo "To install:"
|
||||
echo " sudo dpkg -i ${PACKAGE_NAME}_${VERSION}_${ARCH}.deb"
|
||||
echo " sudo apt-get install -f # Install dependencies if needed"
|
||||
echo ""
|
||||
|
||||
173
packaging/install.sh
Executable file
173
packaging/install.sh
Executable file
@@ -0,0 +1,173 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Adastra Storage Installation Script for Ubuntu 24.04
|
||||
# This script builds and installs the Adastra Storage appliance
|
||||
|
||||
INSTALL_DIR="/opt/adastra-storage"
|
||||
SERVICE_USER="adastra"
|
||||
SERVICE_GROUP="adastra"
|
||||
BUILD_DIR="$(pwd)"
|
||||
PACKAGE_DIR="$BUILD_DIR/packaging"
|
||||
|
||||
echo "=========================================="
|
||||
echo "Adastra Storage Installation Script"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Check if running as root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Please run as root (use sudo)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check Ubuntu version
|
||||
if [ ! -f /etc/os-release ]; then
|
||||
echo "Error: Cannot determine OS version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. /etc/os-release
|
||||
if [ "$ID" != "ubuntu" ] || [ "$VERSION_ID" != "24.04" ]; then
|
||||
echo "Warning: This installer is designed for Ubuntu 24.04"
|
||||
echo "Detected: $ID $VERSION_ID"
|
||||
read -p "Continue anyway? (y/N) " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Step 1: Installing system dependencies..."
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
golang-go \
|
||||
zfsutils-linux \
|
||||
smartmontools \
|
||||
nfs-kernel-server \
|
||||
samba \
|
||||
targetcli-fb \
|
||||
build-essential \
|
||||
git \
|
||||
curl \
|
||||
wget
|
||||
|
||||
# Install MinIO (if not already installed)
|
||||
if ! command -v minio &> /dev/null; then
|
||||
echo "Installing MinIO..."
|
||||
wget -q https://dl.min.io/server/minio/release/linux-amd64/minio -O /usr/local/bin/minio
|
||||
chmod +x /usr/local/bin/minio
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Step 2: Building Adastra Storage application..."
|
||||
|
||||
# Build the application
|
||||
cd "$BUILD_DIR"
|
||||
if [ ! -f go.mod ]; then
|
||||
echo "Error: go.mod not found. Are you in the project root?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build binary
|
||||
echo "Building binary..."
|
||||
go build -o "$BUILD_DIR/appliance" ./cmd/appliance
|
||||
|
||||
if [ ! -f "$BUILD_DIR/appliance" ]; then
|
||||
echo "Error: Build failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Step 3: Creating installation directory structure..."
|
||||
|
||||
# Create directories
|
||||
mkdir -p "$INSTALL_DIR/bin"
|
||||
mkdir -p "$INSTALL_DIR/data"
|
||||
mkdir -p "$INSTALL_DIR/templates"
|
||||
mkdir -p "$INSTALL_DIR/migrations"
|
||||
mkdir -p "$INSTALL_DIR/logs"
|
||||
mkdir -p /etc/systemd/system
|
||||
|
||||
# Create service user if it doesn't exist
|
||||
if ! id "$SERVICE_USER" &>/dev/null; then
|
||||
echo "Creating service user: $SERVICE_USER"
|
||||
useradd -r -s /bin/false -d "$INSTALL_DIR" "$SERVICE_USER"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Step 4: Installing application files..."
|
||||
|
||||
# Copy binary
|
||||
cp "$BUILD_DIR/appliance" "$INSTALL_DIR/bin/adastra-storage"
|
||||
chmod +x "$INSTALL_DIR/bin/adastra-storage"
|
||||
|
||||
# Copy templates
|
||||
cp -r "$BUILD_DIR/internal/templates"/* "$INSTALL_DIR/templates/"
|
||||
|
||||
# Copy migrations
|
||||
cp -r "$BUILD_DIR/migrations"/* "$INSTALL_DIR/migrations/"
|
||||
|
||||
# Copy uninstaller
|
||||
cp "$PACKAGE_DIR/uninstall.sh" "$INSTALL_DIR/uninstall.sh"
|
||||
chmod +x "$INSTALL_DIR/uninstall.sh"
|
||||
|
||||
# Set ownership
|
||||
chown -R "$SERVICE_USER:$SERVICE_GROUP" "$INSTALL_DIR"
|
||||
|
||||
echo ""
|
||||
echo "Step 5: Installing systemd service..."
|
||||
|
||||
# Install systemd service
|
||||
cp "$PACKAGE_DIR/adastra-storage.service" /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
|
||||
# Add service user to necessary groups
|
||||
usermod -aG disk "$SERVICE_USER" || true
|
||||
|
||||
echo ""
|
||||
echo "Step 6: Configuring service..."
|
||||
|
||||
# Create environment file (if needed)
|
||||
if [ ! -f "$INSTALL_DIR/.env" ]; then
|
||||
cat > "$INSTALL_DIR/.env" <<EOF
|
||||
# Adastra Storage Configuration
|
||||
INSTALL_DIR=$INSTALL_DIR
|
||||
DATA_DIR=$INSTALL_DIR/data
|
||||
LOG_DIR=$INSTALL_DIR/logs
|
||||
PORT=8080
|
||||
EOF
|
||||
chown "$SERVICE_USER:$SERVICE_GROUP" "$INSTALL_DIR/.env"
|
||||
chmod 600 "$INSTALL_DIR/.env"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "Installation Complete!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Installation directory: $INSTALL_DIR"
|
||||
echo "Data directory: $INSTALL_DIR/data"
|
||||
echo "Service user: $SERVICE_USER"
|
||||
echo ""
|
||||
echo "To start the service:"
|
||||
echo " systemctl start adastra-storage"
|
||||
echo ""
|
||||
echo "To enable on boot:"
|
||||
echo " systemctl enable adastra-storage"
|
||||
echo ""
|
||||
echo "To check status:"
|
||||
echo " systemctl status adastra-storage"
|
||||
echo ""
|
||||
echo "To view logs:"
|
||||
echo " journalctl -u adastra-storage -f"
|
||||
echo ""
|
||||
echo "Default admin credentials:"
|
||||
echo " Username: admin"
|
||||
echo " Password: admin"
|
||||
echo ""
|
||||
echo "⚠️ IMPORTANT: Change the default password after first login!"
|
||||
echo ""
|
||||
echo "Access the web interface at: http://localhost:8080"
|
||||
echo ""
|
||||
|
||||
97
packaging/uninstall.sh
Executable file
97
packaging/uninstall.sh
Executable file
@@ -0,0 +1,97 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Adastra Storage Uninstaller Script
|
||||
|
||||
INSTALL_DIR="/opt/adastra-storage"
|
||||
SERVICE_USER="adastra"
|
||||
|
||||
echo "=========================================="
|
||||
echo "Adastra Storage Uninstaller"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Check if running as root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Please run as root (use sudo)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Confirm removal
|
||||
echo "This will remove Adastra Storage from your system."
|
||||
echo "Installation directory: $INSTALL_DIR"
|
||||
read -p "Are you sure you want to continue? (y/N) " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Uninstallation cancelled."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Step 1: Stopping and disabling service..."
|
||||
|
||||
# Stop and disable service
|
||||
if systemctl is-active adastra-storage.service >/dev/null 2>&1; then
|
||||
echo "Stopping adastra-storage service..."
|
||||
systemctl stop adastra-storage.service
|
||||
fi
|
||||
|
||||
if systemctl is-enabled adastra-storage.service >/dev/null 2>&1; then
|
||||
echo "Disabling adastra-storage service..."
|
||||
systemctl disable adastra-storage.service
|
||||
fi
|
||||
|
||||
systemctl daemon-reload
|
||||
|
||||
echo ""
|
||||
echo "Step 2: Removing systemd service file..."
|
||||
|
||||
if [ -f /etc/systemd/system/adastra-storage.service ]; then
|
||||
rm -f /etc/systemd/system/adastra-storage.service
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Step 3: Removing application files..."
|
||||
|
||||
# Ask about data preservation
|
||||
read -p "Do you want to preserve data directory? (Y/n) " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||
echo "Removing all files including data..."
|
||||
rm -rf "$INSTALL_DIR"
|
||||
else
|
||||
echo "Preserving data directory..."
|
||||
if [ -d "$INSTALL_DIR/data" ]; then
|
||||
echo "Data directory preserved at: $INSTALL_DIR/data"
|
||||
# Remove everything except data
|
||||
find "$INSTALL_DIR" -mindepth 1 -maxdepth 1 ! -name data -exec rm -rf {} +
|
||||
else
|
||||
rm -rf "$INSTALL_DIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Step 4: Removing service user (optional)..."
|
||||
|
||||
read -p "Remove service user '$SERVICE_USER'? (y/N) " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
if id "$SERVICE_USER" &>/dev/null; then
|
||||
userdel "$SERVICE_USER" 2>/dev/null || true
|
||||
echo "Service user removed."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "Uninstallation Complete!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Note: System dependencies (golang, zfsutils-linux, etc.)"
|
||||
echo " were not removed. Remove them manually if needed:"
|
||||
echo ""
|
||||
echo " apt-get remove golang-go zfsutils-linux smartmontools"
|
||||
echo " nfs-kernel-server samba targetcli-fb"
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user