Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d005ccc919 | |||
| 5df89e7f89 | |||
| f6d72800cb | |||
| 4ff1929a22 | |||
| 46d54ffeee |
+2
-1
@@ -16,4 +16,5 @@
|
||||
.vscode/
|
||||
.idea/
|
||||
mirror/.env
|
||||
update/
|
||||
update/*
|
||||
!update/update.sh
|
||||
|
||||
+13
-7
@@ -3829,7 +3829,6 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function readStatus()
|
||||
{
|
||||
// $this->sd([$this->getWGType(), $this->getInstanceWG()]);
|
||||
$r = $this->ssh($this->getWGType(), $this->getInstanceWG());
|
||||
$r = explode(PHP_EOL, $r);
|
||||
$r = array_filter($r);
|
||||
@@ -4002,14 +4001,21 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function syncPortClients()
|
||||
{
|
||||
$endpoint = $this->ip . ':' . getenv('WGPORT');
|
||||
$clients = $this->readClients();
|
||||
foreach ($clients as $k => $v) {
|
||||
foreach ($v['peers'] as $i => $j) {
|
||||
$clients[$k]['peers'][$i]['Endpoint'] = $endpoint;
|
||||
$endpoint = [
|
||||
$this->ip . ':' . getenv('WGPORT'),
|
||||
$this->ip . ':' . getenv('WG1PORT'),
|
||||
];
|
||||
for ($i=0; $i < 2; $i++) {
|
||||
$this->wg = $i;
|
||||
$clients = $this->readClients();
|
||||
foreach ($clients as $k => $v) {
|
||||
foreach ($v['peers'] as $i => $j) {
|
||||
$clients[$k]['peers'][$i]['Endpoint'] = $endpoint[$i];
|
||||
}
|
||||
}
|
||||
$this->saveClients($clients);
|
||||
}
|
||||
$this->saveClients($clients);
|
||||
unset($this->wg);
|
||||
}
|
||||
|
||||
public function saveClients(array $clients)
|
||||
|
||||
@@ -2,7 +2,7 @@ b:
|
||||
docker compose build
|
||||
u: # запуск контейнеров
|
||||
bash ./update/update.sh &
|
||||
IP=$(shell ip -4 addr | sed -ne 's|^.* inet \([^/]*\)/.* scope global.*$$|\1|p' | awk '{print $1}' | head -1) VER=$(shell git describe --tags) docker compose up -d --force-recreate
|
||||
IP=$(shell curl https://ipinfo.io/ip) VER=$(shell git describe --tags) docker compose up -d --force-recreate
|
||||
d: # остановка контейнеров
|
||||
-kill -9 $(shell cat ./update/update_pid) > /dev/null
|
||||
docker compose down --remove-orphans
|
||||
@@ -54,4 +54,5 @@ s:
|
||||
git status -su
|
||||
c:
|
||||
git add config/
|
||||
git checkout .
|
||||
git checkout .
|
||||
git reset
|
||||
+33
-14
@@ -1,3 +1,7 @@
|
||||
cat /ssh/key.pub > /root/.ssh/authorized_keys
|
||||
ssh-keygen -A
|
||||
exec /usr/sbin/sshd -D -e "$@" &
|
||||
|
||||
INTERFACE=$(route | grep '^default' | grep -o '[^ ]*$')
|
||||
if [ $(cat /etc/wireguard/wg0.conf | wc -c) -eq 0 ]
|
||||
then
|
||||
@@ -13,21 +17,36 @@ fi
|
||||
iptables -t nat -A POSTROUTING --destination 10.10.0.5 -j ACCEPT
|
||||
iptables -t nat -A POSTROUTING -o $INTERFACE -j MASQUERADE
|
||||
ln -s /etc/wireguard/wg0.conf /etc/amnezia/amneziawg/wg0.conf
|
||||
if [ $(cat /pac.json | jq .amnezia) -eq 1 ]
|
||||
if [ "$HOSTNAME" = "wireguard1" ]
|
||||
then
|
||||
awg-quick up wg0
|
||||
if [ $(cat /pac.json | jq .wg1_amnezia) -eq 1 ]
|
||||
then
|
||||
awg-quick up wg0
|
||||
else
|
||||
wg-quick up wg0
|
||||
fi
|
||||
if [ $(cat /pac.json | jq .wg1_blocktorrent) -eq 1 ]
|
||||
then
|
||||
sh /block_torrent.sh
|
||||
fi
|
||||
if [ $(cat /pac.json | jq .wg1_exchange) -eq 1 ]
|
||||
then
|
||||
sh /block_exchange.sh
|
||||
fi
|
||||
else
|
||||
wg-quick up wg0
|
||||
fi
|
||||
cat /ssh/key.pub > /root/.ssh/authorized_keys
|
||||
ssh-keygen -A
|
||||
exec /usr/sbin/sshd -D -e "$@" &
|
||||
if [ $(cat /pac.json | jq .blocktorrent) -eq 1 ]
|
||||
then
|
||||
sh /block_torrent.sh
|
||||
fi
|
||||
if [ $(cat /pac.json | jq .exchange) -eq 1 ]
|
||||
then
|
||||
sh /block_exchange.sh
|
||||
if [ $(cat /pac.json | jq .amnezia) -eq 1 ]
|
||||
then
|
||||
awg-quick up wg0
|
||||
else
|
||||
wg-quick up wg0
|
||||
fi
|
||||
if [ $(cat /pac.json | jq .blocktorrent) -eq 1 ]
|
||||
then
|
||||
sh /block_torrent.sh
|
||||
fi
|
||||
if [ $(cat /pac.json | jq .exchange) -eq 1 ]
|
||||
then
|
||||
sh /block_exchange.sh
|
||||
fi
|
||||
fi
|
||||
tail -f /dev/null
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
pwd=`pwd`
|
||||
> $pwd/update/pipe
|
||||
echo "$$" > $pwd/update/update_pid
|
||||
|
||||
while true
|
||||
do
|
||||
cmd=$(cat $pwd/update/pipe)
|
||||
if [[ -n "$cmd" ]]
|
||||
then
|
||||
docker compose down --remove-orphans
|
||||
git reset --hard
|
||||
git pull > ./update/message
|
||||
IP=$(curl https://ipinfo.io/ip) VER=$(git describe --tags) docker compose up -d --force-recreate
|
||||
bash $pwd/update/update.sh &
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
Reference in New Issue
Block a user