Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
check pid
Browse files Browse the repository at this point in the history
  • Loading branch information
ChisBread committed May 8, 2022
1 parent b7bbc97 commit 2043ba7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup_iptables.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# set -ex
set -ex

# ENABLE ipv4 forward
sysctl -w net.ipv4.ip_forward=1
Expand Down
30 changes: 25 additions & 5 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -ex
setroute() {
/setup_iptables.sh
}
Expand Down Expand Up @@ -31,17 +32,36 @@ fi
if [ ! -d "/etc/clash/dashboard" ]; then
cp -arp /default/clash/dashboard /etc/clash/dashboard
fi
cp /etc/clash/config.yaml /etc/clash/config.yaml.org
python3 /default/clash/utils/override.py "/etc/clash/config.yaml" "$MUST_CONFIG" "$CLASH_HTTP_PORT" "$CLASH_SOCKS_PORT" "$CLASH_TPROXY_PORT" "$CLASH_MIXED_PORT" "$LOG_LEVEL"
chmod -R a+rw /etc/clash
su - clash -c '/usr/bin/clash -d /etc/clash -ext-ctl '"0.0.0.0:$DASH_PORT"' -ext-ui /etc/clash/dashboard/public' 2>&1 >/etc/clash/clash.log &
EXPID=$!
while :
do
PID=`ps -def|grep -P '^clash'|awk '{print $2}'`
if [ "$PID" == "" ]; then
EXPID_EXIST=$(ps aux | awk '{print $2}'| grep -w $EXPID)
if [ ! $EXPID_EXIST ];then
cat /etc/clash/clash.log
exit 1
fi
echo 'waiting for clash ...'
sleep 1
continue
fi
echo $PID > /var/clash.pid
break
done
cat /var/clash.pid
if [ "$IP_ROUTE" == "1" ]; then
echo "set iproutes ..."
set +ex
__=`unsetroute 2>&1 >/dev/null`
set -ex
__=`setroute 2>&1 >/dev/null`
echo "done."
fi
cp /etc/clash/config.yaml /etc/clash/config.yaml.org
python3 /default/clash/utils/override.py "/etc/clash/config.yaml" "$MUST_CONFIG" "$CLASH_HTTP_PORT" "$CLASH_SOCKS_PORT" "$CLASH_TPROXY_PORT" "$CLASH_MIXED_PORT" "$LOG_LEVEL"
chmod -R a+rw /etc/clash
su - clash -c '/usr/bin/clash -d /etc/clash -ext-ctl '"0.0.0.0:$DASH_PORT"' -ext-ui /etc/clash/dashboard/public' 2>&1 >/etc/clash/clash.log &
echo $! > /var/clash.pid
echo "Dashboard Address: http://YOUR_IP:$DASH_PORT/ui"
tail -f /etc/clash/clash.log &
wait

0 comments on commit 2043ba7

Please sign in to comment.