Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script Linux Fedora PostgreSQL #4

Open
Majin0103 opened this issue May 31, 2023 · 0 comments
Open

Script Linux Fedora PostgreSQL #4

Majin0103 opened this issue May 31, 2023 · 0 comments

Comments

@Majin0103
Copy link
Owner

#!/bin/bash

#Functions definition
Search_Postgre_Service(){
SERVICE_NAME=$(systemctl list-unit-files |grep postgresql|awk -F '.' '{print $1}')
}
Memory_usage(){
echo -n " Memory used $1 $2 the service: "
MEM=$(free |grep Mem |awk '{print $3}';)
SWAP=$(free |grep Swap |awk '{print $3}';)
Tot_Mem=$(($MEM + $SWAP))
echo -e "\e[1;31m$Tot_Mem\e[0m"
}

Start(){
Memory_usage before starting;
sudo systemctl start $1 ;
echo -n " Service is: ";
sudo systemctl status $1 | grep Active | awk '{print $2}';
Memory_usage after starting;
}

Stop(){
Memory_usage before stopping;
sudo systemctl stop $1;
echo -n " Service is: ";
sudo systemctl status $1 | grep Active | awk '{print $2}';
Memory_usage after stopping;
}

Status(){
echo -n " Service is: ";
sudo systemctl status $1 | grep Active | awk '{print $2}';
}

#Main program
Search_Postgre_Service
echo -e "\e[1;32mBienvenue dan l'utilitaire PostgreSQL du script!\e[0m\n"
echo -e "\e[1;32mTu navigues sur la version $SERVICE_NAME\e[0m\n"
Search_Postgre_Service
case $1 in
"start") Start $SERVICE_NAME;;
"stop") Stop $SERVICE_NAME;;
"status") Status $SERVICE_NAME;;
"help") echo -e "Script usage:\n PostgreSQL.sh start to start the service \n PostgreSQL.sh stop to stop the service";;
*) echo "Command not found!"
esac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant