Review this AI-generated deployment script against its stated task.
Deploy a signed release archive for one allowlisted systemd service, preserve the previous release, stop gracefully, and fail safely if health verification does not pass.
Shell
#!/usr/bin/env bash
set -e
SERVICE=$1
ARCHIVE_URL=$2
RELEASE_DIR=/opt/apps/$SERVICE
sudo mkdir -p $RELEASE_DIR
curl -sL $ARCHIVE_URL | sudo tar -xz -C $RELEASE_DIR
sudo chmod -R 777 $RELEASE_DIR
for pid in $(pgrep -f $SERVICE); do
sudo kill -9 $pid
done
sudo cp $RELEASE_DIR/$SERVICE.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl start $SERVICE
curl -s http://localhost:8080/health
echo "deployed $SERVICE"
generated code is illustrative, not from any one model