use blade as conmmands template (#444)

* use blade as conmmands template

* fix lint

* fix ssl
This commit is contained in:
Saeed Vaziry
2025-01-27 21:27:58 +01:00
committed by GitHub
parent a73476c1dd
commit cdbde063f0
208 changed files with 1080 additions and 1012 deletions

View File

@ -0,0 +1,9 @@
if ! sudo sed -i 's/php{{ $oldVersion }}/php{{ $newVersion }}/g' /etc/nginx/sites-available/{{ $domain }}; then
echo 'VITO_SSH_ERROR' && exit 1
fi
if ! sudo service nginx restart; then
echo 'VITO_SSH_ERROR' && exit 1
fi
echo "PHP Version Changed to {{ $newVersion }}"

View File

@ -0,0 +1,13 @@
if ! sudo mkdir -p {{ $path }}; then
echo 'VITO_SSH_ERROR' && exit 1
fi
if ! echo "{{ $certificate }}" | sudo tee {{ $certificatePath }}; then
echo 'VITO_SSH_ERROR' && exit 1
fi
if ! echo "{{ $pk }}" | sudo tee {{ $pkPath }}; then
echo 'VITO_SSH_ERROR' && exit 1
fi
echo "Successfully received certificate."

View File

@ -0,0 +1,3 @@
if ! sudo certbot certonly --force-renewal --nginx --noninteractive --agree-tos --cert-name {{ $domain }} -m {{ $email }} {{ $domains }} --verbose; then
echo 'VITO_SSH_ERROR' && exit 1
fi

View File

@ -0,0 +1,7 @@
export DEBIAN_FRONTEND=noninteractive
rm -rf {{ $path }}
mkdir {{ $path }}
chmod -R 755 {{ $path }}

View File

@ -0,0 +1,7 @@
if ! sudo ln -s /etc/nginx/sites-available/{{ $domain }} /etc/nginx/sites-enabled/; then
echo 'VITO_SSH_ERROR' && exit 1
fi
if ! sudo service nginx restart; then
echo 'VITO_SSH_ERROR' && exit 1
fi

View File

@ -0,0 +1,7 @@
rm -rf {{ $path }}
sudo rm /etc/nginx/sites-available/{{ $domain }}
sudo rm /etc/nginx/sites-enabled/{{ $domain }}
echo "Site deleted"

View File

@ -0,0 +1 @@
cat /etc/nginx/sites-available/{{ $domain }}

View File

@ -0,0 +1,4 @@
sudo DEBIAN_FRONTEND=noninteractive apt-get install nginx -y
# install certbot
sudo DEBIAN_FRONTEND=noninteractive apt-get install certbot python3-certbot-nginx -y

View File

@ -0,0 +1,85 @@
user {{ $user }};
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}

View File

@ -0,0 +1,3 @@
location {{ $from }} {
return {{ $mode }} {{ $to }};
}

View File

@ -0,0 +1,12 @@
sudo service nginx stop
sudo DEBIAN_FRONTEND=noninteractive apt-get purge nginx nginx-common nginx-full -y
sudo rm -rf /etc/nginx
sudo rm -rf /var/log/nginx
sudo rm -rf /var/lib/nginx
sudo rm -rf /var/cache/nginx
sudo rm -rf /usr/share/nginx
sudo rm -rf /etc/systemd/system/nginx.service
sudo systemctl daemon-reload

View File

@ -0,0 +1,7 @@
if ! echo '{{ $redirects }}' | sudo tee /etc/nginx/conf.d/{{ $domain }}_redirects; then
echo 'VITO_SSH_ERROR' && exit 1
fi
if ! sudo service nginx restart; then
echo 'VITO_SSH_ERROR' && exit 1
fi

View File

@ -0,0 +1,66 @@
@if ($site->activeSsl && $site->force_ssl)
server {
listen 80;
server_name {{ $site->domain }} {{ $site->getAliasesString() }};
return 301 https://$host$request_uri;
}
@endif
server {
@if (!$site->activeSsl || !$site->force_ssl)
listen 80;
@endif
@if ($site->activeSsl)
listen 443 ssl;
ssl_certificate {{ $site->activeSsl->getCertificatePath() }};
ssl_certificate_key {{ $site->activeSsl->getPkPath() }};
@endif
server_name {{ $site->domain }} {{ $site->getAliasesString() }};
root {{ $site->getWebDirectoryPath() }};
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.html index.php;
charset utf-8;
@if ($site->port)
location / {
try_files $uri $uri/ /index.html;
}
location / {
proxy_pass http://127.0.0.1:{{ $site->port }}/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $remote_addr;
}
@elseif ($site->php_version)
@php
$phpSocket = 'unix:/var/run/php/php-fpm.sock';
if ($site->isIsolated()) {
$phpSocket = "unix:/run/php/php{$site->php_version}-fpm-{$site->user}.sock";
}
@endphp
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass {{ $phpSocket }};
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_hide_header X-Powered-By;
}
@endif
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.html;
location ~ /\.(?!well-known).* {
deny all;
}
}