샤인의 IT (막 적는) 메모장

[Bash] 기본 작성 ( + WEB 서버 실행 스크립트) 본문

Programming/Bash

[Bash] 기본 작성 ( + WEB 서버 실행 스크립트)

신샤인 2022. 1. 22. 17:47
반응형

 

 

기본 문법

 

스크립트 작성 및 Permission 부여한 후 실행

[root@scriptbox scripts]# cat firstscript.sh
#!/bin/bash

### This script prints system info ###
echo "Welcome to Bash script"
echo

#Check system time
echo "###############################"
echo "The uptime of the system is: "
uptime

#Memory Check
echo "###############################"
echo "Memory Utilization"
free -m

#Disk Check
echo "###############################"
echo "Disk Utilization"
df -h

#Shell 실행권한 부여
chmod +x firstscript.sh

#스크립트 실행
[root@scriptbox scripts]# ./firstscript.sh

 

 

Template을 설치하여 WEB 서버를 실행하는 스크립트

 

#httpd script


[root@scriptbox scripts]# cat websetup.sh
#!/bin/bash

# Package Install
sudo yum -y install wget unzip httpd > /dev/null


# Start httpd
echo "Start httpd"
echo "###################################"
sudo systemctl start httpd
sudo systemctl enable httpd


#templete Setup
echo "Templete Setup"
echo "###################################"
mkdir -p /tmp/webfiles
cd /tmp/webfiles

wget https://www.tooplate.com/zip-templates/2124_vertex.zip > /dev/null
unzip 2124_vertex.zip

sudo cp -r 2124_vertex/* /var/www/html/


#restart httpd
echo "httpd restart...."
echo "###################################"
sudo systemctl restart httpd

rm -rf /tmp/webfiles
반응형

'Programming > Bash' 카테고리의 다른 글

[Bash] Export Variable  (0) 2022.01.22
[Bash] Quota & Substitution  (0) 2022.01.22
[Bash] Command Line Argument  (0) 2022.01.22
[Bash] Variable  (0) 2022.01.22
Comments