Commit 989ee28b authored by Your Name's avatar Your Name

update script

parent 89050f65
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
go run keys/main.go go run keys/main.go
./init.sh cog-hello-world:latest privatekey 5000 output:v0.0.10 ./init.sh cog-hello-world:latest 894e3af33d6b3ff825c9bcfdad6902697cadfbd37bdd57f02d4f0abdfe452b475f8c9e654c7ad34e8502d67f0949615895bffde10a2416743a39442730aa2389 5000 output:v0.0.10
``` ```
\ No newline at end of file
#!/bin/bash #!/bin/bash
time=$(date "+%Y-%m-%d_%H:%M:%S") time=$(date "+%Y-%m-%d_%H-%M-%S")
defaultTag=":latest" defaultTag=":latest"
inputImage=${1:-cog-hello-world${defaultTag}} inputImage=${1:-cog-hello-world${defaultTag}}
ciperPrivateKey=${2:-8c4c3af66c696dfe72cdedacf16c02332dfea1de7edd09f2264f5bbdf9122f430ddc9a324d79da4a855e82785a4b675fc3baf0e35f7f46763d3a14233fa072d1} ciperPrivateKey=${2:-8c4c3af66c696dfe72cdedacf16c02332dfea1de7edd09f2264f5bbdf9122f430ddc9a324d79da4a855e82785a4b675fc3baf0e35f7f46763d3a14233fa072d1}
port=${3:-5000} port=${3:-5000}
outputImage=${4:-outputImage_${time}} outputImage=${4:-output-image:${time}}
# 1. 基础镜像 2. 加密密钥 3. 端口 4. 输出镜像 # 1. 基础镜像 2. 加密密钥 3. 端口 4. 输出镜像
...@@ -29,11 +29,40 @@ echo "RUN chmod +x script.sh" >> $dockerfile ...@@ -29,11 +29,40 @@ echo "RUN chmod +x script.sh" >> $dockerfile
echo "CMD ./script.sh" >> $dockerfile echo "CMD ./script.sh" >> $dockerfile
go build -ldflags '-X main.CipherPrivateKey=${ciperPrivateKey}' -o ./proxy go build -ldflags "-X main.CipherPrivateKey=${ciperPrivateKey}" -o ./proxy
# version=$(git describe --tags) # version=$(git describe --tags)
# docker build -f Dockerfile -t aiwithproxy:${version} . # docker build -f Dockerfile -t aiwithproxy:${version} .
docker build -f Dockerfile -t $outputImage .
scriptfile="script.sh"
echo "nohup ./proxy &" > $scriptfile
echo "nohup python -m cog.server.http &" >> $scriptfile
echo "echo \"rm /bin/sh /bin/bash /bin/dash /bin/rbash rm /usr/bin/cp \"" >> $scriptfile
echo "rm /bin/sh /bin/bash /bin/dash /bin/rbash" >> $scriptfile
echo "rm /usr/bin/cp" >> $scriptfile
echo "while /bin/true; do" >> $scriptfile
echo " ps aux |grep proxy |grep -q -v grep" >> $scriptfile
echo " PROCESS_1_STATUS=$?" >> $scriptfile
echo " ps aux |grep cog.server.http |grep -q -v grep" >> $scriptfile
echo " PROCESS_2_STATUS=$?" >> $scriptfile
# If the greps above find anything, they will exit with 0 status
# If they are not both 0, then something is wrong
echo "if [ \$PROCESS_1_STATUS -ne 0 -o \$PROCESS_2_STATUS -ne 0 ]; then" >> $scriptfile
echo " echo \"One of the processes has already exited.\"" >> $scriptfile
echo " exit -1" >> $scriptfile
echo " fi " >> $scriptfile
echo " sleep 60 " >> $scriptfile
echo "done " >> $scriptfile
docker build -f Dockerfile -t $outputImage .
No preview for this file type
#!/bin/bash
# Start the second process
# ./my_second_process -D
# status=$?
# if [ $status -ne 0 ]; then
# echo "Failed to start my_second_process: $status"
# exit $status
# fi
# your_command; if [ $? -ne 0 ]; then echo "Failed to start proxy"; exit 1; fi
#nohup ./proxy ; if [ $? -ne 0 ]; then echo "Failed to start proxy"; exit 1; fi &
nohup ./proxy & nohup ./proxy &
nohup python -m cog.server.http & nohup python -m cog.server.http &
echo "rm /bin/sh /bin/bash /bin/dash /bin/rbash rm /usr/bin/cp " echo "rm /bin/sh /bin/bash /bin/dash /bin/rbash rm /usr/bin/cp "
rm /bin/sh /bin/bash /bin/dash /bin/rbash rm /bin/sh /bin/bash /bin/dash /bin/rbash
rm /usr/bin/cp rm /usr/bin/cp
while /bin/true; do while /bin/true; do
ps aux |grep proxy |grep -q -v grep ps aux |grep proxy |grep -q -v grep
PROCESS_1_STATUS=$? PROCESS_1_STATUS=0
ps aux |grep cog.server.http |grep -q -v grep ps aux |grep cog.server.http |grep -q -v grep
PROCESS_2_STATUS=$? PROCESS_2_STATUS=0
# If the greps above find anything, they will exit with 0 status if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then
# If they are not both 0, then something is wrong echo "One of the processes has already exited."
if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then
echo "One of the processes has already exited."
exit -1 exit -1
fi fi
sleep 60 sleep 60
done done
#!/bin/bash
# Start the second process
# ./my_second_process -D
# status=$?
# if [ $status -ne 0 ]; then
# echo "Failed to start my_second_process: $status"
# exit $status
# fi
# your_command; if [ $? -ne 0 ]; then echo "Failed to start proxy"; exit 1; fi
#nohup ./proxy ; if [ $? -ne 0 ]; then echo "Failed to start proxy"; exit 1; fi &
nohup ./proxy &
nohup python -m cog.server.http &
echo "rm /bin/sh /bin/bash /bin/dash /bin/rbash rm /usr/bin/cp "
rm /bin/sh /bin/bash /bin/dash /bin/rbash
rm /usr/bin/cp
while /bin/true; do
ps aux |grep proxy |grep -q -v grep
PROCESS_1_STATUS=$?
ps aux |grep cog.server.http |grep -q -v grep
PROCESS_2_STATUS=$?
# If the greps above find anything, they will exit with 0 status
# If they are not both 0, then something is wrong
if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then
echo "One of the processes has already exited."
exit -1
fi
sleep 60
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment