1 Star 4 Fork 1

QimingYe/chia

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
init_sys 2.94 KB
一键复制 编辑 原始数据 按行查看 历史
QimingYe 提交于 2021-05-07 17:13 . "init_sys" test passed.
#! /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 ; }
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/procleaf/chia.git
[email protected]:procleaf/chia.git
procleaf
chia
chia
master

搜索帮助