#!/bin/bash function print {if [ $# = 2 ]; then if [ "$1" = "warning" ]; then echo -e "33[33m33[5m$233[0m" elif [ "$1" = "error" ]; then echo -e "33[31m33[5m$233[0m" elif [ "$1" = "notice" ]; then echo -e "33[36m33[5m$233[0m" fi echo $2 elif [ $# = 1 ]; then echo -e "33[32m33[5m$133[0m" echo $1 fi return}#定义显示颜色方案function format_disk(){fdisk /dev/sda << EOFd1d2d3d4np1+1Gnp2+20Gnp3 wqEOFprint "==============fdsik sda to three parttions====================="return 0}#分区大小为boot 1GB swap 20GB /根分区余下空间全用function MKFS(){partprobemkfs.reiserfs -q /dev/sda1 [ $? != 0 ] && print "error" "mkfs sda1 is failed" && exit 0mkswap /dev/sda2 [ $? != 0 ] && print "error" "mkswap sda2 is failed" && exit 0swapon /dev/sda2 [ $? != 0 ] && print "error" "swapon sda2 is failed" && exit 0mkfs.reiserfs -q /dev/sda3 [ $? != 0 ] && print "error" "mkfs sda3 is failed" && exit 0 print "===================make filesystem is OK====================" return 0}#分区类型为reiserfsfunction main(){format_disk;MKFS}main
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索脚本
, echo
, function
, 33
THEN
shell脚本实现ssh登录、shell脚本实现scp、shell脚本实现自动化、shell脚本实现交互、shell脚本实现进度条,以便于您获取更多的相关知识。
时间: 2024-09-11 08:50:38