代码拉取完成,页面将自动刷新
#! /bin/bash
# ----------------------------------------------------------------------------
#
# Init a chia plot system.
#
#
# 05/07/21
#
# ----------------------------------------------------------------------------
set -e
CONFIG_REPO="https://gitee.com/procleaf/repo.git"
APP_LINK="https://github.com/Chia-Network/chia-blockchain/releases/download/1.1.4/chia-blockchain_1.1.4_amd64.deb"
APP_FILE=$(basename ${APP_LINK})
WORK_DIR="/root"
[ $UID -ne 0 ] && { echo "Need to be root." ; exit 1 ; }
cd "${WORK_DIR}"
[ -f ${APP_FILE} ] || \
{ echo "${APP_FILE} not found in directory." ; exit 1 ; }
# Detect OS hard drive.
OS_DISK=$(lsblk | grep -C 1 "/boot" | head -1 | awk '{ print $1 }')
[ $? -ne 0 ] && { echo "Detect OS disk failed" ; exit 1 ; }
echo "OS installed on: ${OS_DISK}"
#read -p "OS installed on ${OS_DISK}, is this correct? " choice
#echo ${choice} | grep -E "No" && exit 1
PARITIONS=$(lsblk | grep -v "${OS_DISK}" | \
grep -E "(sd[a-z]1)|(nvme[0-9]n1p1)" | \
awk -F'─' '{ print $2 }' | awk '{ print $1 }')
HDD_PARTITIONS=$(lsblk | grep -v "${OS_DISK}" | \
grep -E "sd[a-z]1" | awk -F'─' '{ print $2 }' | \
awk '{ print $1 }')
NUM_HDD_PARTITIONS=$(echo -e "${PARITIONS}" | grep -E "sd[a-z]1" | wc -l)
SSD_PARTITIONS=$(lsblk | grep -v "${OS_DISK}" | \
grep -E "nvme[0-9]n1p1" | awk -F'─' '{ print $2 }' | \
awk '{ print $1 }')
NUM_SSD_PARTITIONS=$(echo -e "${PARITIONS}" | grep -E "nvme[0-9]n1p1" | wc -l)
echo "Number of hdd partion(s) detected: $NUM_HDD_PARTITIONS"
for p in $HDD_PARTITIONS ; do
echo $p
done
echo "Number of ssd partion(s) detected: $NUM_SSD_PARTITIONS"
for p in $SSD_PARTITIONS ; do
echo $p
done
i=1
for p in $HDD_PARTITIONS ; do
mkfs.ext4 /dev/${p}
mount_point="/mnt/hdd${i}"
[ -d $mount_point ] || mkdir ${mount_point}
uuid=$(blkid | grep "$p" | grep -v "${OS_DISK}" | awk '{ print $2 }' | sed 's/\"//g')
echo "${uuid} ${mount_point} ext4 defaults 0 0" >> /etc/fstab
let i++;
done
i=1
for p in $SSD_PARTITIONS ; do
mkfs.ext4 /dev/${p}
mount_point="/mnt/ssd${i}"
[ -d $mount_point ] || mkdir ${mount_point}
uuid=$(blkid | grep "$p" | grep -v "${OS_DISK}" | awk '{ print $2 }' | sed 's/\"//g')
echo "${uuid} ${mount_point} ext4 defaults 0 0" >> /etc/fstab
let i++;
done
mount -a || { echo "mount failed, please check /etc/fstab file" ; exit 1 ; }
# install apps.
apt-get install -y wget git tmux vim htop sysstat || \
{ echo "Install app failed." ; exit 1 ; }
git clone ${CONFIG_REPO} || \
{ echo "git clone failed." ; exit 1 ; }
# This is too slow because of github.com.
#wget "${APP_LINK}" || \
#{ echo "wget failed." ; exit 1 ; }
dpkg -i ${APP_FILE} || \
{ echo "install app failed" ; exit 1 ; }
CMD_FILE=$(dpkg -L $(echo ${APP_FILE} | awk -F'_' '{ print $1 }') | grep "chia$")
ln -sf $CMD_FILE /usr/local/bin/
chia init || \
{ echo "chia init failed." ; exit 1 ; }
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。