Compare commits
6 Commits
upip
...
bc380a60a4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc380a60a4 | ||
|
|
d9d691db1d | ||
|
|
e2a09dcaaf | ||
|
|
8a64ccaa3f | ||
| 9b2731ea9c | |||
| 8e8442a2e7 |
2
cbr.get
2
cbr.get
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
URL=https://www.cbr.ru/scripts/XML_daily.asp
|
URL=https://www.cbr.ru/scripts/XML_daily.asp
|
||||||
OUT=/var/www/html/cbr.xml
|
OUT=/var/www/html/cbr/cur.xml
|
||||||
wget $URL -O $OUT
|
wget $URL -O $OUT
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash -e
|
||||||
# https://habr.com/ru/articles/735712/
|
# https://habr.com/ru/articles/735712/
|
||||||
certbot certonly --manual --preferred-challenges http -d "kornerr.ru"
|
certbot certonly --manual --preferred-challenges http -d "kornerr.ru"
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash -e
|
||||||
# https://habr.com/ru/articles/735712/
|
# https://habr.com/ru/articles/735712/
|
||||||
brew install certbot
|
brew install certbot
|
||||||
11
cert/vpsRenew
Executable file
11
cert/vpsRenew
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
SDIR=$(cd "$(dirname "$0")" ; pwd -P)
|
||||||
|
T=$SDIR/../step
|
||||||
|
|
||||||
|
STEP=0
|
||||||
|
source $T/ensureRootUser
|
||||||
|
source $T/copyNginxACMEConfig
|
||||||
|
source $T/restartNginx
|
||||||
|
|
||||||
|
source $T/copyNginxProdConfig
|
||||||
|
source $T/restartNginx
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
apt install nginx
|
|
||||||
cp nginx/cfg /etc/nginx/sites-enabled/default
|
|
||||||
systemctl restart nginx
|
|
||||||
10
nginx/acme.cfg
Normal file
10
nginx/acme.cfg
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Serve only through HTTP while updating the certificate
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name kornerr.ru;
|
||||||
|
root /var/www/html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ server {
|
|||||||
return 301 https://$server_name$request_uri;
|
return 301 https://$server_name$request_uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Serve through HTTPS only
|
||||||
server {
|
server {
|
||||||
listen 443 ssl;
|
listen 443 ssl;
|
||||||
server_name kornerr.ru;
|
server_name kornerr.ru;
|
||||||
@@ -26,7 +27,6 @@ server {
|
|||||||
|
|
||||||
root /var/www/html;
|
root /var/www/html;
|
||||||
|
|
||||||
# Add index.php to the list if you are using PHP
|
|
||||||
index index.html;
|
index index.html;
|
||||||
|
|
||||||
server_name _;
|
server_name _;
|
||||||
@@ -36,6 +36,7 @@ server {
|
|||||||
# as directory, then fall back to displaying a 404.
|
# as directory, then fall back to displaying a 404.
|
||||||
try_files $uri $uri/ =404;
|
try_files $uri $uri/ =404;
|
||||||
add_header "Access-Control-Allow-Origin" "*";
|
add_header "Access-Control-Allow-Origin" "*";
|
||||||
|
add_header "Cache-Control" "max-age=43200";
|
||||||
# Remove CORS.
|
# Remove CORS.
|
||||||
if ($request_method = "OPTIONS") {
|
if ($request_method = "OPTIONS") {
|
||||||
add_header "Access-Control-Allow-Origin" "*";
|
add_header "Access-Control-Allow-Origin" "*";
|
||||||
9
nginx/setup
Executable file
9
nginx/setup
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
SDIR=$(cd "$(dirname "$0")" ; pwd -P)
|
||||||
|
T=$SDIR/../step
|
||||||
|
|
||||||
|
STEP=0
|
||||||
|
source $T/ensureRootUser
|
||||||
|
source $T/installNginx
|
||||||
|
source $T/copyNginxProdConfig
|
||||||
|
source $T/restartNginx
|
||||||
50
publish.dbg
Executable file
50
publish.dbg
Executable file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
DST_DIR=/var/www/dbg
|
||||||
|
KMP_FILE=kornerr-ver-browser
|
||||||
|
KMP_FILE_EXT=js
|
||||||
|
MAIN_BRANCH=main
|
||||||
|
REPO_DIR=/home/kornerr/repo-ru
|
||||||
|
REPO_URL=https://github.com/kornerr/ru
|
||||||
|
|
||||||
|
# Clone if the directory does not exist
|
||||||
|
if [ ! -d "$REPO_DIR" ]; then
|
||||||
|
git clone $REPO_URL $REPO_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the latest changes
|
||||||
|
cd $REPO_DIR
|
||||||
|
git checkout -f $MAIN_BRANCH
|
||||||
|
git fetch --all
|
||||||
|
|
||||||
|
# Find out the latest commit in the whole repo
|
||||||
|
#git branch -av --sort=-committerdate
|
||||||
|
#git branch -av --sort=-committerdate | tr -s ' ' | head -n1
|
||||||
|
cmt=`git branch -av --sort=-committerdate | tr -s ' ' | head -n1 | cut -d' ' -f3`
|
||||||
|
echo "Latest commit: $cmt"
|
||||||
|
|
||||||
|
# Switch to the latest commit
|
||||||
|
git checkout -f $cmt
|
||||||
|
|
||||||
|
# Copy dist
|
||||||
|
mkdir -p $DST_DIR
|
||||||
|
rm -fR $DST_DIR/*
|
||||||
|
cp -R dist/* $DST_DIR
|
||||||
|
|
||||||
|
# Rename kornerr-ver-browser.js to work around caching
|
||||||
|
kmpWas=$KMP_FILE.$KMP_FILE_EXT
|
||||||
|
kmpNow=${KMP_FILE}_`uuidgen`.$KMP_FILE_EXT
|
||||||
|
mv $DST_DIR/$kmpWas $DST_DIR/$kmpNow
|
||||||
|
|
||||||
|
# Replace text in a file
|
||||||
|
function replace {
|
||||||
|
file=$1
|
||||||
|
was=$2
|
||||||
|
now=$3
|
||||||
|
cmd="sed -i 's|$was|$now|g' $file"
|
||||||
|
eval "$cmd"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Rename references
|
||||||
|
replace $DST_DIR/bank.html "$kmpWas" "$kmpNow"
|
||||||
|
replace $DST_DIR/quiz.html "$kmpWas" "$kmpNow"
|
||||||
15
publish.prod
Executable file
15
publish.prod
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
DBG_DIR=/var/www/dbg
|
||||||
|
DST_DIR=/var/www/html
|
||||||
|
|
||||||
|
# Remove current prod
|
||||||
|
rm -fR $DST_DIR
|
||||||
|
|
||||||
|
# Copy dbg to prod
|
||||||
|
rsync -aivc --delete $DBG_DIR/ $DST_DIR
|
||||||
|
|
||||||
|
# Symlink
|
||||||
|
cd $DST_DIR
|
||||||
|
ln -s ../cbr
|
||||||
|
ln -s ../dbg
|
||||||
4
publish.setup
Executable file
4
publish.setup
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
CMD="0 20 * * * kornerr /home/kornerr/vps/publish.dbg"
|
||||||
|
CRON_FILE=/etc/cron.d/dbg
|
||||||
|
echo "$CMD" > $CRON_FILE
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
acl tul src 83.221.16.80
|
acl tul src 83.221.16.86
|
||||||
http_access allow tul
|
http_access allow tul
|
||||||
http_access deny all
|
http_access deny all
|
||||||
http_port 3128
|
http_port 3128
|
||||||
|
|
||||||
|
|||||||
5
step/copyNginxACMEConfig
Normal file
5
step/copyNginxACMEConfig
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
STEP=$((STEP+1))
|
||||||
|
echo -e "\n> > > > Шаг №$STEP. Копируем настройки Nginx для ACME"
|
||||||
|
cp $SDIR/../nginx/acme.cfg /etc/nginx/sites-enabled/default
|
||||||
5
step/copyNginxProdConfig
Normal file
5
step/copyNginxProdConfig
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
STEP=$((STEP+1))
|
||||||
|
echo -e "\n> > > > Шаг №$STEP. Копируем боевые настройки Nginx"
|
||||||
|
cp $SDIR/../nginx/prod.cfg /etc/nginx/sites-enabled/default
|
||||||
9
step/ensureRootUser
Normal file
9
step/ensureRootUser
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# https://askubuntu.com/a/15856
|
||||||
|
|
||||||
|
STEP=$((STEP+1))
|
||||||
|
echo -e "\n> > > > Шаг №$STEP. Проверяем запуск из-под root"
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo "ОШИБКА: Перезапустите как root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
5
step/installNginx
Normal file
5
step/installNginx
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
STEP=$((STEP+1))
|
||||||
|
echo -e "\n> > > > Шаг №$STEP. Устанавливаем Nginx"
|
||||||
|
apt install nginx
|
||||||
5
step/restartNginx
Normal file
5
step/restartNginx
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
STEP=$((STEP+1))
|
||||||
|
echo -e "\n> > > > Шаг №$STEP. Перезапускаем Nginx"
|
||||||
|
systemctl restart nginx
|
||||||
Reference in New Issue
Block a user