You've already forked Atomcms-edit
docs: rewrite README in English with Linux/Windows setup guides and add auto-install scripts
This commit is contained in:
Executable
+288
@@ -0,0 +1,288 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_URL="https://gitlab.epicnabbo.nl/RemcoEpic/atomcms-edit.git"
|
||||
INSTALL_DIR="/var/www/atomcms"
|
||||
DB_NAME="habbo"
|
||||
DB_USER="root"
|
||||
DB_PASS=""
|
||||
|
||||
MAGENTA='\033[0;35m'
|
||||
CYAN='\033[0;36m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
log() { echo -e "${MAGENTA}[AtomCMS]${NC} $1"; }
|
||||
ok() { echo -e "${GREEN}[ OK ]${NC} $1"; }
|
||||
info() { echo -e "${CYAN}[ INFO ]${NC} $1"; }
|
||||
warn() { echo -e "${YELLOW}[ WARN ]${NC} $1"; }
|
||||
err() { echo -e "${RED}[FAILED]${NC} $1"; exit 1; }
|
||||
|
||||
if [[ $EUID -eq 0 ]]; then
|
||||
SUDO=""
|
||||
else
|
||||
SUDO="sudo"
|
||||
warn "Not running as root. I'll use sudo where needed."
|
||||
fi
|
||||
|
||||
detect_distro() {
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
OS=$ID
|
||||
OS_VER=$VERSION_ID
|
||||
else
|
||||
err "Cannot detect OS. Only Ubuntu/Debian are supported."
|
||||
fi
|
||||
}
|
||||
|
||||
install_deps_debian() {
|
||||
log "Installing system dependencies..."
|
||||
$SUDO apt update
|
||||
$SUDO apt install -y curl wget git unzip nginx mariadb-server \
|
||||
php8.3 php8.3-cli php8.3-fpm php8.3-mysql php8.3-xml \
|
||||
php8.3-mbstring php8.3-curl php8.3-zip php8.3-bcmath \
|
||||
php8.3-gd php8.3-sockets php8.3-intl
|
||||
ok "System dependencies installed"
|
||||
}
|
||||
|
||||
install_deps_ubuntu() {
|
||||
install_deps_debian
|
||||
}
|
||||
|
||||
install_composer() {
|
||||
if command -v composer &>/dev/null; then
|
||||
ok "Composer already installed"
|
||||
return
|
||||
fi
|
||||
log "Installing Composer..."
|
||||
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
|
||||
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
|
||||
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
|
||||
rm composer-setup.php
|
||||
err "Composer installer checksum mismatch"
|
||||
fi
|
||||
php composer-setup.php --quiet
|
||||
rm composer-setup.php
|
||||
$SUDO mv composer.phar /usr/local/bin/composer
|
||||
ok "Composer installed"
|
||||
}
|
||||
|
||||
install_node_yarn() {
|
||||
if command -v node &>/dev/null && command -v yarn &>/dev/null; then
|
||||
ok "Node.js and Yarn already installed"
|
||||
return
|
||||
fi
|
||||
log "Installing Node.js and Yarn..."
|
||||
curl -fsSL https://deb.nodesource.com/setup_22.x | $SUDO bash -
|
||||
$SUDO apt install -y nodejs
|
||||
$SUDO corepack enable
|
||||
$SUDO corepack install -g yarn@latest
|
||||
ok "Node.js $(node -v) and Yarn $(yarn -v) installed"
|
||||
}
|
||||
|
||||
setup_database() {
|
||||
log "Setting up MariaDB/MySQL..."
|
||||
$SUDO systemctl enable --now mariadb 2>/dev/null || true
|
||||
$SUDO mysql -u root -e "CREATE DATABASE IF NOT EXISTS \`$DB_NAME\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" 2>/dev/null || true
|
||||
ok "Database '$DB_NAME' ready"
|
||||
}
|
||||
|
||||
clone_project() {
|
||||
if [ -d "$INSTALL_DIR" ] && [ -f "$INSTALL_DIR/artisan" ]; then
|
||||
ok "Project already cloned at $INSTALL_DIR"
|
||||
return
|
||||
fi
|
||||
log "Cloning project..."
|
||||
$SUDO mkdir -p "$(dirname "$INSTALL_DIR")"
|
||||
git clone "$REPO_URL" "$INSTALL_DIR"
|
||||
ok "Project cloned to $INSTALL_DIR"
|
||||
}
|
||||
|
||||
configure_env() {
|
||||
log "Configuring environment..."
|
||||
cd "$INSTALL_DIR"
|
||||
if [ ! -f .env ]; then
|
||||
cp .env.example .env
|
||||
read -rp "Database password (leave empty for root without password): " DB_PASS
|
||||
sed -i "s/DB_DATABASE=.*/DB_DATABASE=$DB_NAME/" .env
|
||||
sed -i "s/DB_USERNAME=.*/DB_USERNAME=$DB_USER/" .env
|
||||
sed -i "s/DB_PASSWORD=.*/DB_PASSWORD=$DB_PASS/" .env
|
||||
php artisan key:generate --quiet
|
||||
ok ".env configured and APP_KEY generated"
|
||||
else
|
||||
info ".env already exists, skipping"
|
||||
fi
|
||||
}
|
||||
|
||||
install_php_deps() {
|
||||
log "Installing PHP dependencies..."
|
||||
cd "$INSTALL_DIR"
|
||||
composer install --no-interaction --optimize-autoloader --no-dev
|
||||
ok "PHP dependencies installed"
|
||||
}
|
||||
|
||||
install_node_deps() {
|
||||
log "Installing Node dependencies..."
|
||||
cd "$INSTALL_DIR"
|
||||
yarn install --frozen-lockfile
|
||||
ok "Node dependencies installed"
|
||||
}
|
||||
|
||||
run_migrations() {
|
||||
log "Running migrations and seeders..."
|
||||
cd "$INSTALL_DIR"
|
||||
php artisan migrate --seed --force || true
|
||||
ok "Migrations and seeders complete"
|
||||
}
|
||||
|
||||
build_assets() {
|
||||
log "Building frontend assets..."
|
||||
cd "$INSTALL_DIR"
|
||||
yarn build:all
|
||||
ok "Frontend assets built"
|
||||
}
|
||||
|
||||
set_permissions() {
|
||||
log "Setting filesystem permissions..."
|
||||
cd "$INSTALL_DIR"
|
||||
$SUDO chown -R www-data:www-data storage bootstrap/cache public/build 2>/dev/null || true
|
||||
$SUDO chmod -R 775 storage bootstrap/cache
|
||||
ok "Permissions set"
|
||||
}
|
||||
|
||||
configure_nginx() {
|
||||
log "Configuring Nginx..."
|
||||
read -rp "Enter your domain name (e.g. example.com or localhost): " DOMAIN
|
||||
$SUDO tee /etc/nginx/sites-available/atomcms > /dev/null <<EOF
|
||||
server {
|
||||
listen 80;
|
||||
server_name $DOMAIN;
|
||||
root $INSTALL_DIR/public;
|
||||
|
||||
add_header X-Frame-Options "SAMEORIGIN";
|
||||
add_header X-Content-Type-Options "nosniff";
|
||||
|
||||
index index.php;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
location / {
|
||||
try_files \$uri \$uri/ /index.php?\$query_string;
|
||||
}
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
error_page 404 /index.php;
|
||||
|
||||
location ~ \.php\$ {
|
||||
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
|
||||
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
|
||||
location ~ /\.(?!well-known).* {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
if [ -f /etc/nginx/sites-enabled/default ]; then
|
||||
$SUDO rm /etc/nginx/sites-enabled/default
|
||||
fi
|
||||
$SUDO ln -sf /etc/nginx/sites-available/atomcms /etc/nginx/sites-enabled/
|
||||
$SUDO nginx -t || err "Nginx config test failed"
|
||||
$SUDO systemctl reload nginx
|
||||
ok "Nginx configured for $DOMAIN"
|
||||
}
|
||||
|
||||
configure_apache() {
|
||||
log "Configuring Apache..."
|
||||
read -rp "Enter your domain name (e.g. example.com or localhost): " DOMAIN
|
||||
$SUDO a2enmod rewrite
|
||||
$SUDO tee /etc/apache2/sites-available/atomcms.conf > /dev/null <<EOF
|
||||
<VirtualHost *:80>
|
||||
ServerName $DOMAIN
|
||||
DocumentRoot $INSTALL_DIR/public
|
||||
|
||||
<Directory $INSTALL_DIR/public>
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
ErrorLog \${APACHE_LOG_DIR}/atomcms-error.log
|
||||
CustomLog \${APACHE_LOG_DIR}/atomcms-access.log combined
|
||||
</VirtualHost>
|
||||
EOF
|
||||
$SUDO a2ensite atomcms.conf || true
|
||||
$SUDO a2dissite 000-default.conf || true
|
||||
$SUDO systemctl reload apache2
|
||||
ok "Apache configured for $DOMAIN"
|
||||
}
|
||||
|
||||
setup_finalize() {
|
||||
log "Finalizing installation..."
|
||||
cd "$INSTALL_DIR"
|
||||
php artisan storage:link --force 2>/dev/null || true
|
||||
php artisan optimize:clear 2>/dev/null || true
|
||||
$SUDO systemctl restart php8.3-fpm 2>/dev/null || true
|
||||
ok "Installation complete!"
|
||||
}
|
||||
|
||||
main() {
|
||||
echo ""
|
||||
echo -e "${MAGENTA}╔══════════════════════════════════════╗${NC}"
|
||||
echo -e "${MAGENTA}║ AtomCMS Auto Installer (Linux) ║${NC}"
|
||||
echo -e "${MAGENTA}╚══════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
|
||||
detect_distro
|
||||
echo -e "Detected: ${CYAN}$OS $OS_VER${NC}"
|
||||
echo ""
|
||||
|
||||
case "$OS" in
|
||||
ubuntu) install_deps_ubuntu ;;
|
||||
debian) install_deps_debian ;;
|
||||
*) err "Unsupported distro: $OS. Only Ubuntu/Debian are supported." ;;
|
||||
esac
|
||||
|
||||
install_composer
|
||||
install_node_yarn
|
||||
clone_project
|
||||
configure_env
|
||||
install_php_deps
|
||||
install_node_deps
|
||||
setup_database
|
||||
run_migrations
|
||||
build_assets
|
||||
set_permissions
|
||||
|
||||
echo ""
|
||||
info "Select web server:"
|
||||
echo "1) Nginx (recommended)"
|
||||
echo "2) Apache"
|
||||
read -rp "Choice [1]: " WS_CHOICE
|
||||
case "${WS_CHOICE:-1}" in
|
||||
2) configure_apache ;;
|
||||
*) configure_nginx ;;
|
||||
esac
|
||||
|
||||
setup_finalize
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}╔══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${GREEN}║ AtomCMS is ready! ║${NC}"
|
||||
echo -e "${GREEN}║ ║${NC}"
|
||||
echo -e "${GREEN}║ Visit: http://$DOMAIN ║${NC}"
|
||||
echo -e "${GREEN}║ Admin: http://$DOMAIN/admin ║${NC}"
|
||||
echo -e "${GREEN}║ ║${NC}"
|
||||
echo -e "${GREEN}║ Run the repair tool for extra checks: ║${NC}"
|
||||
echo -e "${GREEN}║ php artisan atom:check --fix ║${NC}"
|
||||
echo -e "${GREEN}╚══════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
main
|
||||
Reference in New Issue
Block a user