Skip to content

Commit 89cba64

Browse files
committed
Add cleanup
1 parent 5dc485c commit 89cba64

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

scripts/install.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,15 @@ cd "$WORKDIR"
107107
git clone https://github.com/TIOJ-INFOR-Online-Judge/tioj.git
108108
git clone https://github.com/TIOJ-INFOR-Online-Judge/tioj-judge.git
109109

110+
function Cleanup {
111+
sudo rm -rf $PASSENGER_LOG
112+
}
113+
110114
# Install gems
111115
cd "$WORKDIR/tioj"
112116
gem install passenger:'~> 6' -N
113117
PASSENGER_LOG=$(sudo mktemp -d)
118+
trap Cleanup EXIT
114119
sudo chmod 755 $PASSENGER_LOG
115120
export rvmsudo_secure_path=1
116121
rvmsudo -b bash -c "passenger-install-nginx-module --force-colors --auto --auto-download --languages ruby > $PASSENGER_LOG/log 2>&1; touch $PASSENGER_LOG/finished"
@@ -182,7 +187,6 @@ until stat $PASSENGER_LOG/finished > /dev/null 2>&1; do
182187
sleep 1
183188
done
184189
kill $TAIL_PID
185-
sudo rm -rf $PASSENGER_LOG
186190
sudo sed -i "s/^.*nobody.*$/user $USER;/" /opt/nginx/conf/nginx.conf
187191
sudo sed -i 's/http {/\0\n passenger_app_env production;/' /opt/nginx/conf/nginx.conf
188192
sudo sed -i "s|^[^#]*server_name.*localhost.*$|\0\n passenger_enabled on;\n root $(pwd)/public;|" /opt/nginx/conf/nginx.conf

0 commit comments

Comments
 (0)