200字
帕鲁服务搭建以及自动化脚本学习
2025-12-01
2025-12-01

解决方案 ✅

下载正确的 Linux 版本

# 删除当前的文件
rm -rf steamcmd*

# 下载Linux版本
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz

# 解压
tar -xvzf steamcmd_linux.tar.gz

# 运行
./steamcmd.sh

或者使用官方推荐的方式:

# 创建steamcmd目录
mkdir ~/steamcmd && cd ~/steamcmd

# 下载
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz

# 解压
tar -xvzf steamcmd_linux.tar.gz

# 首次运行(会自动更新)
./steamcmd.sh

方法1:安装32位库支持(推荐)

# 启用32位架构支持
sudo dpkg --add-architecture i386

# 更新软件源
sudo apt update

# 安装32位库
sudo apt install lib32gcc-s1

# 或者安装完整的32位支持包
sudo apt install lib32gcc-s1 lib32stdc++6 libc6-i386

# 再次运行steamcmd
./steamcmd.sh

方法2:使用Docker运行(更简洁)

如果你已经安装了 Docker(从截图看系统有 docker 服务),可以这样:

# 拉取官方镜像
docker pull steamcmd/steamcmd

# 运行容器
docker run -it steamcmd/steamcmd

客户端下载命令 🚀

./steamcmd.sh +force_install_dir /root/palworld +login anonymous +app_update 2394010 validate +quit

查看下载的文件

cd /root/palworld
ls -la

配置文件

第一步:查看默认配置文件 📄

cat DefaultPalWorldSettings.ini

这个文件包含了所有默认设置,我们需要把它复制到正确的位置。

第二步:先运行一次服务器生成配置目录 🚀

./PalServer.sh

运行后会生成必要的配置目录。让它运行几秒钟后按 Ctrl+C 停止

第三步:复制配置文件到正确位置 📋

# 创建配置目录(如果不存在)
mkdir -p Pal/Saved/Config/LinuxServer

# 复制默认配置
cp DefaultPalWorldSettings.ini Pal/Saved/Config/LinuxServer/PalWorldSettings.ini

第四步:编辑配置文件(重要!)⚙️

# 使用nano编辑器打开配置文件
nano Pal/Saved/Config/LinuxServer/PalWorldSettings.ini

重要配置项:

找到这些参数并修改:

ServerName="你的服务器名称"
ServerPassword="设置密码(可选)"
ServerPlayerMaxNum=32
PublicPort=8211
PublicIP="你的服务器公网IP"
RCONEnabled=True
RCONPort=25575

执行以下命令直接更新配置文件 📝

cat > Pal/Saved/Config/LinuxServer/PalWorldSettings.ini << 'EOF'
; This configuration file is a sample of the default server settings.
; Changes to this file will NOT be reflected on the server.
; To change the server settings, modify Pal/Saved/Config/LinuxServer/PalWorldSettings.ini.
[/Script/Pal.PalGameWorldSettings]
OptionSettings=(Difficulty=None,RandomizerType=None,RandomizerSeed="",bIsRandomizerPalLevelRandom=False,DayTimeSpeedRate=1.000000,NightTimeSpeedRate=1.000000,ExpRate=1.000000,PalCaptureRate=1.000000,PalSpawnNumRate=1.000000,PalDamageRateAttack=1.000000,PalDamageRateDefense=1.000000,PlayerDamageRateAttack=1.000000,PlayerDamageRateDefense=1.000000,PlayerStomachDecreaceRate=1.000000,PlayerStaminaDecreaceRate=1.000000,PlayerAutoHPRegeneRate=1.000000,PlayerAutoHpRegeneRateInSleep=1.000000,PalStomachDecreaceRate=1.000000,PalStaminaDecreaceRate=1.000000,PalAutoHPRegeneRate=1.000000,PalAutoHpRegeneRateInSleep=1.000000,BuildObjectHpRate=1.000000,BuildObjectDamageRate=1.000000,BuildObjectDeteriorationDamageRate=1.000000,CollectionDropRate=1.000000,CollectionObjectHpRate=1.000000,CollectionObjectRespawnSpeedRate=1.000000,EnemyDropItemRate=1.000000,DeathPenalty=All,bEnablePlayerToPlayerDamage=False,bEnableFriendlyFire=False,bEnableInvaderEnemy=True,bActiveUNKO=False,bEnableAimAssistPad=True,bEnableAimAssistKeyboard=False,DropItemMaxNum=3000,DropItemMaxNum_UNKO=100,BaseCampMaxNum=128,BaseCampWorkerMaxNum=15,DropItemAliveMaxHours=1.000000,bAutoResetGuildNoOnlinePlayers=False,AutoResetGuildTimeNoOnlinePlayers=72.000000,GuildPlayerMaxNum=20,BaseCampMaxNumInGuild=4,PalEggDefaultHatchingTime=72.000000,WorkSpeedRate=1.000000,AutoSaveSpan=30.000000,bIsMultiplay=False,bIsPvP=False,bHardcore=False,bPalLost=False,bCharacterRecreateInHardcore=False,bCanPickupOtherGuildDeathPenaltyDrop=False,bEnableNonLoginPenalty=True,bEnableFastTravel=True,bIsStartLocationSelectByMap=True,bExistPlayerAfterLogout=False,bEnableDefenseOtherGuildPlayer=False,bInvisibleOtherGuildBaseCampAreaFX=False,bBuildAreaLimit=False,ItemWeightRate=1.000000,CoopPlayerMaxNum=4,ServerPlayerMaxNum=32,ServerName="JINGSU",ServerDescription="",AdminPassword="",ServerPassword="qweqwe123",PublicPort=8211,PublicIP="154.51.63.30",RCONEnabled=True,RCONPort=25575,Region="",bUseAuth=True,BanListURL="https://api.palworldgame.com/api/banlist.txt",RESTAPIEnabled=False,RESTAPIPort=8212,bShowPlayerList=False,ChatPostLimitPerMinute=30,CrossplayPlatforms=(Steam,Xbox,PS5,Mac),bIsUseBackupSaveData=True,LogFormatType=Text,bIsShowJoinLeftMessage=True,SupplyDropSpan=180,EnablePredatorBossPal=True,MaxBuildingLimitNum=0,ServerReplicatePawnCullDistance=15000.000000,bAllowGlobalPalboxExport=True,bAllowGlobalPalboxImport=False,EquipmentDurabilityDamageRate=1.000000,ItemContainerForceMarkDirtyInterval=1.000000,ItemCorruptionMultiplier=1.000000)
EOF

验证配置是否正确 ✅

cat Pal/Saved/Config/LinuxServer/PalWorldSettings.ini | grep -E "ServerName|ServerPassword|PublicIP|RCONEnabled"

启动服务器 🚀

./PalServer.sh

创建普通用户运行服务器 🔧

方法1:创建专用用户(推荐)✅

# 1. 创建palworld用户
useradd -m -s /bin/bash palworld

# 2. 将服务器文件移动到palworld用户目录
mv /root/palworld /home/palworld/
chown -R palworld:palworld /home/palworld/palworld

# 3. 切换到palworld用户
su - palworld

# 4. 进入服务器目录
cd /home/palworld/palworld

# 5. 启动服务器
./PalServer.sh

方法2:使用sudo以普通用户身份运行 🔄

# 创建用户(如果还没创建)
useradd -m -s /bin/bash palworld

# 更改所有权
chown -R palworld:palworld /root/palworld

# 使用sudo以palworld用户运行
sudo -u palworld /root/palworld/PalServer.sh

自动化配置脚本【单行格式不适用】

# 1. 创建脚本
cat > /usr/local/bin/palworld-config-easy << 'SCRIPT_EOF'
#!/bin/bash
# palworld_easy_config.sh
# 幻兽帕鲁服务器简易配置修改脚本

# ============= 配置区域 =============
CONFIG_FILE="/home/palworld/palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini"
BACKUP_DIR="/root/palworld_backups"

# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'

# ============= 函数定义 =============

print_header() {
    clear
    echo -e "${BLUE}╔════════════════════════════════════════╗${NC}"
    echo -e "${BLUE}║   幻兽帕鲁服务器配置修改工具 v1.0   ║${NC}"
    echo -e "${BLUE}╚════════════════════════════════════════╝${NC}"
    echo ""
    echo -e "${GREEN}配置文件:${NC} $CONFIG_FILE"
    echo ""
}

print_success() {
    echo -e "${GREEN}✓${NC} $1"
}

print_error() {
    echo -e "${RED}✗${NC} $1"
}

print_info() {
    echo -e "${YELLOW}ℹ${NC} $1"
}

# 检查配置文件
check_config() {
    if [ ! -f "$CONFIG_FILE" ]; then
        print_error "配置文件不存在: $CONFIG_FILE"
        exit 1
    fi
}

# 备份配置
backup_config() {
    mkdir -p "$BACKUP_DIR"
    timestamp=$(date +"%Y%m%d_%H%M%S")
    backup_file="${BACKUP_DIR}/backup_${timestamp}.ini"
    cp "$CONFIG_FILE" "$backup_file"
    print_success "配置已备份: $backup_file"
}

# 修改配置项
update_config() {
    local key=$1
    local value=$2
    
    if grep -q "^${key}=" "$CONFIG_FILE"; then
        sed -i "s|^${key}=.*|${key}=${value}|" "$CONFIG_FILE"
    elif grep -q "^#${key}=" "$CONFIG_FILE"; then
        sed -i "s|^#${key}=.*|${key}=${value}|" "$CONFIG_FILE"
    else
        sed -i "/\[\/Script\/Pal.PalGameWorldSettings\]/a ${key}=${value}" "$CONFIG_FILE"
    fi
    
    print_success "已修改: ${key}=${value}"
}

# 获取当前配置值
get_current_value() {
    local key=$1
    local value=$(grep "^${key}=" "$CONFIG_FILE" | cut -d'=' -f2)
    if [ -z "$value" ]; then
        echo "未设置"
    else
        echo "$value"
    fi
}

# 显示当前所有配置
show_current_config() {
    print_header
    echo -e "${BLUE}当前配置:${NC}"
    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
    echo "1. 经验倍率:         $(get_current_value 'ExpRate')"
    echo "2. 捕获倍率:         $(get_current_value 'PalCaptureRate')"
    echo "3. 游戏难度:         $(get_current_value 'Difficulty')"
    echo "4. 白天速度倍率:     $(get_current_value 'DayTimeSpeedRate')"
    echo "5. 夜晚速度倍率:     $(get_current_value 'NightTimeSpeedRate')"
    echo "6. PVP 开关:         $(get_current_value 'bEnablePlayerToPlayerDamage')"
    echo "7. 玩家攻击倍率:     $(get_current_value 'PlayerDamageRateAttack')"
    echo "8. 玩家防御倍率:     $(get_current_value 'PlayerDamageRateDefense')"
    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
    echo ""
}

# 快速预设
quick_preset() {
    print_header
    echo -e "${BLUE}快速预设配置${NC}"
    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
    echo "1. 简单模式   - 双倍经验、容易捕获、玩家强化"
    echo "2. 困难模式   - 减半经验、困难捕获、敌人强化"
    echo "3. PVP 模式   - 开启 PVP、普通难度"
    echo "4. 休闲模式   - 五倍经验、超容易捕获"
    echo "5. 默认设置   - 恢复所有默认值"
    echo ""
    read -p "请选择预设 [1-5]: " choice
    
    backup_config
    
    case $choice in
        1)
            print_info "应用简单模式..."
            update_config "ExpRate" "2.0"
            update_config "PalCaptureRate" "2.0"
            update_config "Difficulty" "None"
            update_config "PlayerDamageRateAttack" "1.5"
            update_config "PlayerDamageRateDefense" "1.5"
            update_config "bEnablePlayerToPlayerDamage" "False"
            print_success "简单模式已应用"
            ;;
        2)
            print_info "应用困难模式..."
            update_config "ExpRate" "0.5"
            update_config "PalCaptureRate" "0.5"
            update_config "Difficulty" "Hard"
            update_config "PlayerDamageRateAttack" "0.8"
            update_config "PlayerDamageRateDefense" "0.8"
            print_success "困难模式已应用"
            ;;
        3)
            print_info "应用 PVP 模式..."
            update_config "bEnablePlayerToPlayerDamage" "True"
            update_config "Difficulty" "Normal"
            print_success "PVP 模式已应用"
            ;;
        4)
            print_info "应用休闲模式..."
            update_config "ExpRate" "5.0"
            update_config "PalCaptureRate" "5.0"
            update_config "Difficulty" "None"
            update_config "DayTimeSpeedRate" "0.5"
            update_config "NightTimeSpeedRate" "0.5"
            update_config "PlayerDamageRateAttack" "2.0"
            update_config "PlayerDamageRateDefense" "2.0"
            print_success "休闲模式已应用"
            ;;
        5)
            print_info "恢复默认设置..."
            update_config "ExpRate" "1.0"
            update_config "PalCaptureRate" "1.0"
            update_config "Difficulty" "Normal"
            update_config "DayTimeSpeedRate" "1.0"
            update_config "NightTimeSpeedRate" "1.0"
            update_config "PlayerDamageRateAttack" "1.0"
            update_config "PlayerDamageRateDefense" "1.0"
            update_config "bEnablePlayerToPlayerDamage" "False"
            print_success "默认设置已恢复"
            ;;
        *)
            print_error "无效选择"
            ;;
    esac
    
    read -p "按回车继续..."
}

# 主菜单
main_menu() {
    while true; do
        show_current_config
        echo -e "${BLUE}请选择操作:${NC}"
        echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
        echo "1. 修改经验倍率"
        echo "2. 修改捕获倍率"
        echo "3. 快速预设配置 ⭐"
        echo "4. 查看完整配置文件"
        echo "5. 恢复最新备份"
        echo "0. 退出"
        echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
        echo ""
        read -p "请输入选项 [0-5]: " option
        
        case $option in
            1)
                print_header
                echo "当前经验倍率: $(get_current_value 'ExpRate')"
                read -p "请输入新的经验倍率 (建议 1.0-10.0): " new_value
                if [[ $new_value =~ ^[0-9]+\.?[0-9]*$ ]]; then
                    backup_config
                    update_config "ExpRate" "$new_value"
                fi
                read -p "按回车继续..."
                ;;
            2)
                print_header
                echo "当前捕获倍率: $(get_current_value 'PalCaptureRate')"
                read -p "请输入新的捕获倍率 (建议 0.5-5.0): " new_value
                if [[ $new_value =~ ^[0-9]+\.?[0-9]*$ ]]; then
                    backup_config
                    update_config "PalCaptureRate" "$new_value"
                fi
                read -p "按回车继续..."
                ;;
            3) quick_preset ;;
            4)
                cat "$CONFIG_FILE"
                read -p "按回车继续..."
                ;;
            5)
                latest=$(ls -t "$BACKUP_DIR"/*.ini 2>/dev/null | head -n1)
                if [ -n "$latest" ]; then
                    cp "$latest" "$CONFIG_FILE"
                    print_success "已恢复备份: $latest"
                else
                    print_error "没有可用的备份"
                fi
                read -p "按回车继续..."
                ;;
            0)
                print_info "感谢使用,再见!"
                exit 0
                ;;
            *)
                print_error "无效选项"
                sleep 1
                ;;
        esac
    done
}

# ============= 主程序入口 =============
check_config
main_menu
SCRIPT_EOF

# 2. 添加执行权限
chmod +x /usr/local/bin/palworld-config-easy

# 3. 测试运行
palworld-config-easy

验证配置是否正确 ✅

# 查看配置文件内容
cat /home/palworld/palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini | head -20

# 或者搜索特定配置
grep -E "ExpRate|PalCaptureRate|Difficulty" /home/palworld/palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini

现在可以直接运行了! 🎉

palworld-config-easy

完全生效的命令

restart-palworld-final【重启生效】

#!/bin/bash

CONFIG="/home/palworld/palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini"

echo "修改配置并重启服务器..."

mkdir -p /root/palworld_backups

cp "$CONFIG" "/root/palworld_backups/backup_$(date +%Y%m%d_%H%M%S).ini"

sed -i 's/ExpRate=[^,)]*/ExpRate=10.000000/g' "$CONFIG"

sed -i 's/PalCaptureRate=[^,)]*/PalCaptureRate=5.000000/g' "$CONFIG"

sed -i 's/Difficulty=[^,)]*/Difficulty=None/g' "$CONFIG"

sed -i 's/WorkSpeedRate=[^,)]*/WorkSpeedRate=3.000000/g' "$CONFIG"

echo "✓ 配置已修改"

echo ""

PALSERVER_PID=$(pgrep -f "PalServer-Linux-Shipping")

if [-n "$PALSERVER_PID"]; then

echo "停止服务器..."

kill $PALSERVER_PID

sleep 10

pkill -9 -f "PalServer-Linux-Shipping" 2>/dev/null

fi

echo "启动服务器..."

su - palworld -c "cd /home/palworld/palworld && screen -dmS palserver ./PalServer.sh"

sleep 10

if pgrep -f "PalServer-Linux-Shipping" > /dev/null; then

echo "✓ 服务器重启成功!"

ps aux | grep "PalServer-Linux-Shipping" | grep -v grep

else

echo "❌ 启动失败,请检查日志"

fi

启动

su - palworld -c "cd /home/palworld/palworld && screen -dmS palserver ./PalServer.sh" && sleep 15 && echo "服务器状态:" && ps

aux | grep PalServer-Linux | grep -v grep && echo "" && su - palworld -c"screen -ls"

echo "修改配置..." 【生效】

sed -i 's/ExpRate=[^,)]*/ExpRate=10.000000/g' "$CONFIG"

sed -i 's/PalCaptureRate=[^,)]*/PalCaptureRate=5.000000/g' "$CONFIG"

sed -i 's/Difficulty=[^,)]*/Difficulty=None/g' "$CONFIG"

sed -i 's/WorkSpeedRate=[^,)]*/WorkSpeedRate=3.000000/g' "$CONFIG"

评论