dockerized
This commit is contained in:
83
deploy.sh
83
deploy.sh
@@ -19,7 +19,7 @@ NC='\033[0m' # No Color
|
||||
INSTALL_DIR="/opt/oltalama"
|
||||
LOG_DIR="/var/log/oltalama"
|
||||
BACKUP_DIR="${INSTALL_DIR}/backups"
|
||||
USER="www-data"
|
||||
USER="oltalama" # Tüm sistemler için ortak kullanıcı
|
||||
NODE_VERSION="20"
|
||||
|
||||
# Fonksiyonlar
|
||||
@@ -62,6 +62,21 @@ check_os() {
|
||||
OS=$ID
|
||||
VERSION=$VERSION_ID
|
||||
print_success "İşletim sistemi tespit edildi: $PRETTY_NAME"
|
||||
|
||||
# Paket yöneticisi tespit et
|
||||
if command -v apt-get &> /dev/null; then
|
||||
PKG_MANAGER="apt"
|
||||
print_info "Paket yöneticisi: APT (Debian/Ubuntu)"
|
||||
elif command -v dnf &> /dev/null; then
|
||||
PKG_MANAGER="dnf"
|
||||
print_info "Paket yöneticisi: DNF (RedHat/Oracle/Fedora)"
|
||||
elif command -v yum &> /dev/null; then
|
||||
PKG_MANAGER="yum"
|
||||
print_info "Paket yöneticisi: YUM (RedHat/CentOS)"
|
||||
else
|
||||
print_error "Desteklenen paket yöneticisi bulunamadı!"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
print_error "İşletim sistemi tespit edilemedi!"
|
||||
exit 1
|
||||
@@ -80,8 +95,13 @@ install_nodejs() {
|
||||
fi
|
||||
|
||||
# NodeSource repository ekle
|
||||
curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash -
|
||||
apt-get install -y nodejs
|
||||
if [[ "$PKG_MANAGER" == "apt" ]]; then
|
||||
curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash -
|
||||
apt-get install -y nodejs
|
||||
elif [[ "$PKG_MANAGER" == "dnf" ]] || [[ "$PKG_MANAGER" == "yum" ]]; then
|
||||
curl -fsSL https://rpm.nodesource.com/setup_${NODE_VERSION}.x | bash -
|
||||
$PKG_MANAGER install -y nodejs
|
||||
fi
|
||||
|
||||
print_success "Node.js $(node -v) kuruldu."
|
||||
print_success "npm $(npm -v) kuruldu."
|
||||
@@ -89,8 +109,20 @@ install_nodejs() {
|
||||
|
||||
install_dependencies() {
|
||||
print_info "Sistem bağımlılıkları kuruluyor..."
|
||||
apt-get update
|
||||
apt-get install -y git curl wget build-essential sqlite3
|
||||
|
||||
if [[ "$PKG_MANAGER" == "apt" ]]; then
|
||||
apt-get update
|
||||
apt-get install -y git curl wget build-essential sqlite3
|
||||
elif [[ "$PKG_MANAGER" == "dnf" ]] || [[ "$PKG_MANAGER" == "yum" ]]; then
|
||||
$PKG_MANAGER update -y
|
||||
# EPEL repository (bazı paketler için gerekli)
|
||||
$PKG_MANAGER install -y epel-release 2>/dev/null || true
|
||||
# Paketleri kur
|
||||
$PKG_MANAGER install -y git curl wget gcc-c++ make sqlite
|
||||
# Development tools
|
||||
$PKG_MANAGER groupinstall -y "Development Tools" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
print_success "Sistem bağımlılıkları kuruldu."
|
||||
}
|
||||
|
||||
@@ -110,6 +142,18 @@ setup_directories() {
|
||||
print_success "Dizinler oluşturuldu."
|
||||
}
|
||||
|
||||
create_user() {
|
||||
print_info "Sistem kullanıcısı kontrol ediliyor..."
|
||||
|
||||
if id "$USER" &>/dev/null; then
|
||||
print_success "Kullanıcı '$USER' zaten mevcut."
|
||||
else
|
||||
print_info "Kullanıcı '$USER' oluşturuluyor..."
|
||||
useradd -r -s /bin/bash -d $INSTALL_DIR -m $USER
|
||||
print_success "Kullanıcı '$USER' oluşturuldu."
|
||||
fi
|
||||
}
|
||||
|
||||
install_project() {
|
||||
print_info "Proje dosyaları kontrol ediliyor..."
|
||||
|
||||
@@ -441,6 +485,9 @@ setup_firewall() {
|
||||
print_info "Firewall ayarlanıyor..."
|
||||
|
||||
if command -v ufw &> /dev/null; then
|
||||
# Ubuntu/Debian - UFW
|
||||
print_info "UFW kullanılıyor..."
|
||||
|
||||
# SSH izin ver
|
||||
ufw allow 22/tcp comment 'SSH'
|
||||
|
||||
@@ -460,9 +507,30 @@ setup_firewall() {
|
||||
echo "y" | ufw enable
|
||||
fi
|
||||
|
||||
print_success "Firewall ayarlandı."
|
||||
print_success "Firewall ayarlandı (UFW)."
|
||||
elif command -v firewall-cmd &> /dev/null; then
|
||||
# RedHat/Oracle/CentOS - firewalld
|
||||
print_info "firewalld kullanılıyor..."
|
||||
|
||||
# firewalld'yi başlat ve aktifleştir
|
||||
systemctl start firewalld 2>/dev/null || true
|
||||
systemctl enable firewalld 2>/dev/null || true
|
||||
|
||||
# HTTP/HTTPS izin ver
|
||||
firewall-cmd --permanent --add-service=http
|
||||
firewall-cmd --permanent --add-service=https
|
||||
firewall-cmd --permanent --add-service=ssh
|
||||
|
||||
# Backend ve Frontend portları sadece localhost'tan erişilebilir
|
||||
# (reverse proxy kullanılacağı için dışarıdan erişim kapalı)
|
||||
|
||||
# Yeniden yükle
|
||||
firewall-cmd --reload
|
||||
|
||||
print_success "Firewall ayarlandı (firewalld)."
|
||||
else
|
||||
print_warning "UFW bulunamadı, firewall ayarları atlanıyor."
|
||||
print_warning "Firewall bulunamadı, firewall ayarları atlanıyor."
|
||||
print_warning "Güvenlik için manuel olarak firewall yapılandırmanız önerilir."
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -540,6 +608,7 @@ main() {
|
||||
install_dependencies
|
||||
install_nodejs
|
||||
install_pm2
|
||||
create_user
|
||||
setup_directories
|
||||
install_project
|
||||
install_backend
|
||||
|
||||
Reference in New Issue
Block a user