[工具] Shell 批量设置官方软件源 (openSUSE Leap 15.2 版)

介绍

基本信息

作者:朱明宇
名称:批量设置官方软件源(openSUSE 版)
作用:批量设置官方软件源(openSUSE 版)

使用方法

1. 服务器清单 $add_repo_servers_list.txt 每个服务器名占用 1 行,并和此脚本放在同一目录下
2. 在此脚本的分割线内写入相应的内容
3. 给此脚本添加执行权限
4. 执行此脚本

脚本分割线里的变量

add_repo_servers_list.txt #指定存放要设置官方软件源的文件

注意

1. 此脚本执行前必须要先保证执行此脚本的用户能无密码 ssh 远程这些远程服务器
2. 服务器的系统需要是 openSUSE 15.2 版本
3. 服务器系统要配置好可用的软件源(最好是软件数量最多的官方版本)
4. 这些远程服务器要能够连接外网

脚本

#!/bin/bash

####################### Separator ########################

add_repo_servers_list.txt

####################### Separator ########################

cat add_repo_servers_list.txt
read -p "will add opensuse_leap_15.2 repo please input y " a
echo $a

if [ "$a" != "y" ];then
        echo "you don't agree so exit now"
        exit
fi

for i in `awk '{print $1}' add_repo_servers_list.txt`
do
        ssh $i '
        sudo -u root su - root -c "zypper mr -da"
        sudo -u root su - root -c "zypper ar -fcg http://download.opensuse.org/distribution/leap/15.2/repo/oss/ OpenSUSE_Leap_152_x64_update-oss"
        sudo -u root su - root -c "zypper ar -fcg http://download.opensuse.org/distribution/leap/15.2/repo/non-oss/ OpenSUSE_Leap_152_x64_update-non-oss"
        sudo -u root su - root -c "zypper ar -fcg http://download.opensuse.org/update/leap/15.2/oss/ OpenSUSE_Leap_152_x64_oss"
        sudo -u root su - root -c "zypper ar -fcg http://download.opensuse.org/update/leap/15.2/non-oss/ OpenSUSE_Leap_152_x64_non-oss"
        sudo -u root su - root -c "zypper ref"
done

[步骤] 软件源的设置 (openSUSE 版) (本地镜像版)

步骤一:加载本地镜像到系统光驱

(步骤略)

步骤二:挂载本地镜像

# mount /dev/cdrom /mnt

(补充:这里以挂载 /dev/sr1 到 /mnt 目录为例)

步骤三:添加本地镜像里的软件源

# zypper ar file:///mnt/Module-Basesystem openSUSE15-Base

或者:

# zypper ar -f /mnt/Module-Basesystem openSUSE15-Base

(补充:这里以将 /mnt/Module-Basesystem 添加到软件源并命名为 openSUSE15-Base 为例)

[命令] Linux 命令 convert (转换图片文件)

内容一:convert 命令的使用格式

# convert <input options> <output file name> <output options> <output file name>

内容二:convert 命令的使用案例

2.1 案例一:直接转换某一个文件

# convert "a.png" "a.png.jpg"

(补充:这里以将 a.png 转换成 a.png.jpg 为例)

2.2 案例二:转换当前目录下的所有文件

# ls -1 *.png | xargs -n 1 bash -c 'convert "$0" "${0%.png}.jpg"'

(补充:这里以将当前目录下的所有 *.png 文件转换成 *.png.jpg 文件)