首页
找靠谱产品
找解决方案
找靠谱公司
找案例
找对的人
专家智库
悬赏任务
SAAS
ToB门户
了解全球最新的ToB事件
论坛
潜水/灌水快乐,沉淀知识,认识更多同行。
ToB圈子
加入IT圈,遇到更多同好之人。
微博
Follow
记录
Doing
博客
Blog
文库
业界最专业的IT文库,上传资料也可以赚钱
下载
分享
Share
排行榜
Ranklist
相册
Album
应用中心
qidao123.com ToB IT社区-企服评测·应用市场
»
论坛
›
数据库
›
Oracle
›
shell安装http启动脚本
返回列表
发新帖
shell安装http启动脚本
[复制链接]
发表于 2024-10-16 12:46:26
|
显示全部楼层
|
阅读模式
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要
登录
才可以下载或查看,没有账号?
立即注册
×
使用case语法安装httpd服务
[root@localhost shell]# cat httpd_start1.sh
#!/bin/bash
# This script manages the Apache HTTP server.
# by author rivers on 2024-10-12
# 查抄是否提供了参数
if [ -z "$1" ]; then
echo "Usage: $0 {start|stop|restart|status}"
exit 1
fi
# 界说变量
HTTPD_SERVICE="httpd"
HTTPD_CONFIG="/etc/httpd/conf/httpd.conf"
# 查抄 httpd 是否已安装
if ! command -v $HTTPD_SERVICE &> /dev/null; then
echo "Error: $HTTPD_SERVICE is not installed."
exit 1
fi
# 查抄
配置
文件是否存在
if [ ! -f "$HTTPD_CONFIG" ]; then
echo "Error: Configuration file $HTTPD_CONFIG does not exist."
exit 1
fi
# 使用 case 语句处理差别的命令
case "$1" in
start)
echo "Starting $HTTPD_SERVICE..."
if sudo systemctl start $HTTPD_SERVICE; then
echo "$HTTPD_SERVICE started successfully."
else
echo "Failed to start $HTTPD_SERVICE."
exit 1
fi
;;
stop)
echo "Stopping $HTTPD_SERVICE..."
if sudo systemctl stop $HTTPD_SERVICE; then
echo "$HTTPD_SERVICE stopped successfully."
else
echo "Failed to stop $HTTPD_SERVICE."
exit 1
fi
;;
restart)
echo "Restarting $HTTPD_SERVICE..."
if sudo systemctl restart $HTTPD_SERVICE; then
echo "$HTTPD_SERVICE restarted successfully."
else
echo "Failed to restart $HTTPD_SERVICE."
exit 1
fi
;;
status)
echo "Checking $HTTPD_SERVICE status..."
sudo systemctl status $HTTPD_SERVICE
;;
*)
echo "Invalid option: $1"
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0
实验脚本
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复
使用道具
举报
返回列表
怀念夏天
+ 我要发帖
登录后关闭弹窗
登录参与点评抽奖 加入IT实名职场社区
去登录
微信订阅号
微信服务号
微信客服(加群)
H5
小程序
快速回复
返回顶部
返回列表