|
本帖最后由 feifenspace 于 2024-6-21 13:12 编辑
1、把代码保存为clouddrive-2-installer-linuxx64.sh
vi clouddrive-2-installer-linuxx64.sh
粘贴代码保存
2、确保你的脚本是正确的且具有执行权限。你可以使用以下命令来确保脚本具有执行权限:
chmod +x clouddrive-2-installer-linuxx64.sh
3、如果你想安装RoonBridge,请使用以下命令:
sudo ./clouddrive-2-installer-linuxx64.sh install
- #!/bin/bash
- # 安装CloudDrive2的OpenRC启动脚本
- # 函数:检查并安装依赖的软件包
- check_install_package() {
- local package_name=$1
- # 检查软件包是否已安装
- if ! emerge -s $package_name | grep "\[ Installed versions: .* \]" &>/dev/null; then
- echo "安装 $package_name..."
- emerge $package_name
- fi
- }
- # 函数:配置fuse3并确保fusermount3命令可用
- configure_fuse() {
- # 安装fuse3软件包
- check_install_package sys-fs/fuse3
- # 确认/etc/fuse.conf中user_allow_other行前的注释符#已被删除
- echo "修改/etc/fuse.conf..."
- sed -i 's/^#user_allow_other/user_allow_other/' /etc/fuse.conf
- }
- # 函数:下载并安装CloudDrive2
- install_clouddrive2() {
- local version="0.7.6"
- local download_url="https://github.com/cloud-fs/cloud-fs.github.io/releases/download/v$version/clouddrive-2-linux-x86_64-$version.tgz"
- local install_dir="/opt/clouddrive-2-linux-x86_64-$version"
- local init_script="/etc/init.d/clouddrive2"
- # 下载CloudDrive2安装包并解压
- echo "下载并解压CloudDrive2..."
- cd /tmp
- wget $download_url
- tar zxvf clouddrive-2-linux-x86_64-$version.tgz -C /opt
- # 创建OpenRC启动脚本
- echo "创建OpenRC启动脚本..."
- cat <<EOL >$init_script
- #!/sbin/openrc-run
- command="$install_dir/clouddrive"
- command_args=""
- pidfile="/var/run/clouddrive2.pid"
- output_log="/var/log/clouddrive2.log"
- error_log="/var/log/clouddrive2.err"
- depend() {
- need localmount
- after firewall
- }
- start_pre() {
- checkpath -d -m 0755 -o root:root /var/run/clouddrive2
- }
- start() {
- ebegin "Starting CloudDrive2"
- start-stop-daemon --start --background --make-pidfile --pidfile \$pidfile --exec \$command -- \$command_args >>\$output_log 2>>\$error_log
- eend $?
- }
- stop() {
- ebegin "Stopping CloudDrive2"
- start-stop-daemon --stop --quiet --pidfile \$pidfile --exec \$command >>\$output_log 2>>\$error_log
- eend $?
- }
- EOL
- # 设置启动脚本权限并添加到启动项
- chmod +x $init_script
- rc-update add clouddrive2 default
- # 启动CloudDrive2服务
- echo "启动CloudDrive2服务..."
- rc-service clouddrive2 start
- echo "CloudDrive2安装完成并正在运行!版本:$version"
- }
- # 主程序入口
- main() {
- configure_fuse
- install_clouddrive2
- }
- # 执行主程序
- main
复制代码
|
|