中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何利用onedrive加packerpebuilder實現本地網絡統一裝機

發布時間:2021-11-24 14:38:36 來源:億速云 閱讀:138 作者:柒染 欄目:云計算

如何利用onedrive加packerpebuilder實現本地網絡統一裝機,相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。

今天,我們將用onedrve結合packerpebuilder實現本地也能像云主機一樣裝機,使遠程成為本地裝機app,實際上這個思路自packerpebuilder一開始就有了,只是一直沒有找到合適能用的網盤。

前置改動

把tmpmirror也消除了。調整了一些注釋,如整合checkdeps和selectmirror為prepare prerequisites,selectmirror經過重構變成select1stvalidmirrorfrom3():

function Select1stValidMirrorFrom3(){

  [ $# -ge 1 ] || exit 1

  declare -A MirrorTocheck
  MirrorTocheck=(["Debian0"]="" ["Debian1"]="" ["Debian2"]="")
  
  echo "$1" |sed 's/\ //g' |grep -q '^http://\|^https://\|^ftp://' && MirrorTocheck[Debian0]=$(echo "$1" |sed 's/\ //g');
  echo "$2" |sed 's/\ //g' |grep -q '^http://\|^https://\|^ftp://' && MirrorTocheck[Debian1]=$(echo "$2" |sed 's/\ //g');
  echo "$3" |sed 's/\ //g' |grep -q '^http://\|^https://\|^ftp://' && MirrorTocheck[Debian2]=$(echo "$3" |sed 's/\ //g');

  for mirror in $(echo "${!MirrorTocheck[@]}" |sed 's/\ /\n/g' |sort -n |grep "^Debian")
    do
      CurMirror="${MirrorTocheck[$mirror]}"

      [ -n "$CurMirror" ] || continue

      # CheckPass1='0';
      # DistsList="$(wget --no-check-certificate -qO- "$CurMirror/dists/" |grep -o 'href=.*/"' |cut -d'"' -f2 |sed '/-\|old\|Debian\|experimental\|stable\|test\|sid\|devel/d' |grep '^[^/]' |sed -n '1h;1!H;$g;s/\n//g;s/\//\;/g;$p')";
      # for DIST in `echo "$DistsList" |sed 's/;/\n/g'`
        # do
          # [[ "$DIST" == "jessie" ]] && CheckPass1='1' && break;
        # done
      # [[ "$CheckPass1" == '0' ]] && {
        # echo -ne '\njessie not find in $CurMirror/dists/, Please check it! \n\n'
        # bash $0 error;
        # exit 1;
      # }

      CheckPass2=0
      ImageFile="SUB_MIRROR/dists/jessie/main/installer-amd64/current/images/netboot/debian-installer/amd64/initrd.gz"
      [ -n "$ImageFile" ] || exit 1
      URL=`echo "$ImageFile" |sed "s#SUB_MIRROR#${CurMirror}#g"`
      wget --no-check-certificate --spider --timeout=3 -o /dev/null "$URL"
      [ $? -eq 0 ] && CheckPass2=1 && echo "$CurMirror" && break
    done

    [[ $CheckPass2 == 0 ]] && {
      echo -ne "\033[31mError! \033[0minitrd.gz not find in $CurMirror/jessie/main/installer-amd64/current/images/netboot/debian-installer/amd64/! \n";
      bash $0 error;
      exit 1;
    }
}

MIRROR=$(Select1stValidMirrorFrom3 'http://httpredir.debian.org/debian' 'http://www.shalol.com/cn/d/debian' 'http://http://archive.debian.org/debian')
[ -n "$MIRROR" ] && echo -en "Select Mirror ......:" && echo -en "[\033[32m ${MIRROR} \033[0m]\n" || exit 1

主體改動

整合prepare parepare dist files包括downloading basic kernel and rootfs files(將它提前,邏輯更合理。)和downloading repo pkgs files,,以及接下來的PrepareDDessentials(其原來內部下載deb的邏輯整合到與下載full udeb一起),,并將它們都變成可復用的函數和函數調用buildrepo()和PrepareDDessentials().

prepare parepare dist files與prepare others是并列的:前三者是大資源文件,后三者是小參數文件,將二者中間延時變量變成2s,各內部延時3s(內部還去掉了細節方面,肯定情況下的一些echo輸出,改為直接exit 1,改為由主要的幾句話來echo,界面輸出更清),共5s

wget要調用ssl client才能tls certificate已完善,buildrepo()更強大,支持sed "s/(+|~)/-/g"處理鏈接中的+號和~號(tcb上的onemanager不支持這類特殊符號),和更強大更邏輯清楚的拉取安裝deb pkgs支持:

IncPkgrepo='1'

declare -A OPTPKGS
OPTPKGS=(
  ["libc1"]="pool/main/g/glibc/libc6_2.28-10_amd64.deb"
  ["fmtlibc"]="xz"
  ["binlibc"]=""

  ["common1"]="pool/main/g/gnutls28/libgnutls30_3.6.7-4+deb10u3_amd64.deb"
  ["common2"]="pool/main/p/p11-kit/libp11-kit0_0.23.15-2_amd64.deb"
  ["common3"]="pool/main/libt/libtasn1-6/libtasn1-6_4.13-3_amd64.deb"
  ["common4"]="pool/main/n/nettle/libnettle6_3.4.1-1_amd64.deb"
  ["common5"]="pool/main/n/nettle/libhogweed4_3.4.1-1_amd64.deb"
  ["common6"]="pool/main/g/gmp/libgmp10_6.1.2+dfsg-4_amd64.deb"
  ["fmtcommon"]="xz"
  ["bincommon"]=""

  ["busybox1"]="pool/main/b/busybox/busybox_1.30.1-4_amd64.deb"
  ["fmtbusybox"]="xz"
  ["binbusybox"]="bin/busybox"

  ["wgetssl1"]="pool/main/libi/libidn2/libidn2-0_2.0.5-1+deb10u1_amd64.deb"
  ["wgetssl2"]="pool/main/libp/libpsl/libpsl5_0.20.2-2_amd64.deb"
  ["wgetssl3"]="pool/main/p/pcre2/libpcre2-8-0_10.32-5_amd64.deb"
  ["wgetssl4"]="pool/main/u/util-linux/libuuid1_2.33.1-0.1_amd64.deb"
  ["wgetssl5"]="pool/main/z/zlib/zlib1g_1.2.11.dfsg-1_amd64.deb"
  ["wgetssl6"]="pool/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u8_amd64.deb"
  ["wgetssl7"]="pool/main/o/openssl/openssl_1.0.1t-1+deb8u8_amd64.deb"
  ["wgetssl8"]="pool/main/w/wget/wget_1.20.1-1.1_amd64.deb"
  ["fmtwgetssl"]="xz"
  ["binwgetssl"]="usr/bin/wget"

  ["webfs1"]="pool/main/libf/libffi/libffi6_3.2.1-9_amd64.deb"
  ["webfs2"]="pool/main/m/mime-support/mime-support_3.62_all.deb"
  ["webfs3"]="pool/main/libu/libunistring/libunistring2_0.9.10-1_amd64.deb"
  ["webfs4"]="pool/main/w/webfs/webfs_1.21-ds1-12_amd64.deb"
  ["fmtwebfs"]="xz"
  ["binwebfs"]=""
)

function buildrepo(){

  if [[ "$IncPkgrepo" == '1' ]]; then

    echo -e "Downloading full udebs pkg files..... [\033[32m ${MIRROR}/dists/jessie/main/debian-installer/binary-amd64/Packages.gz \033[0m]\n"

    repodir='/tmp/boot/var/log/debian'
    mkdir -p $repodir

    udeburl=".*pool\/main\(.*\)udeb.*"
    wget --no-check-certificate -qO- "$MIRROR/dists/jessie/main/debian-installer/binary-amd64/Packages.gz" |gunzip -dc|sed "/$udeburl/!d"|sed "s/Filename: //g"|while read line
    do
      path=${line%/*}
      mkdir -p $repodir/$path
      file=${line##*/}
      wget --no-check-certificate -qO $repodir/$path/$(echo $file|sed "s/\(+\|~\)/-/g") $MIRROR/$line
    done

    mkdir -p $repodir/dists/jessie/main/binary-amd64/
    mkdir -p $repodir/dists/jessie/main/debian-installer/binary-amd64/
    mkdir -p $repodir/dists/jessie/main/installer-amd64/current/images/

    wget --no-check-certificate -qO $repodir/dists/jessie/Release $MIRROR/dists/jessie/Release
    wget --no-check-certificate -qO $repodir/dists/jessie/main/binary-amd64/Release $MIRROR/dists/jessie/main/binary-amd64/Release
    wget --no-check-certificate -qO $repodir/dists/jessie/main/debian-installer/binary-amd64/Release $MIRROR/dists/jessie/main/debian-installer/binary-amd64/Release
    wget --no-check-certificate -qO $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages.gz $MIRROR/dists/jessie/main/debian-installer/binary-amd64/Packages.gz; \
    orisize=$(cat $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages.gz | wc -c); \
    orimd5=$(md5sum $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages.gz| awk '{ print $1 }'); \
    orisha1=$(sha1sum $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages.gz| awk '{ print $1 }'); \
    orisha256=$(sha256sum $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages.gz| awk '{ print $1 }'); \
    gunzip -c $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages.gz > $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages; \
    rm -rf $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages.gz; \
    sed -i "s/\(+\|~\)/-/g" $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages; \
    gzip -c $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages > $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages.gz; \
    rm -rf $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages; \
    cursize=$(cat $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages.gz | wc -c); \
    curmd5=$(md5sum $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages.gz| awk '{ print $1 }'); \
    cursha1=$(sha1sum $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages.gz| awk '{ print $1 }'); \
    cursha256=$(sha256sum $repodir/dists/jessie/main/debian-installer/binary-amd64/Packages.gz| awk '{ print $1 }')

    toreplace="main\/debian-installer\/binary-amd64\/Packages.gz"
    linenoarray=($(grep -n $toreplace $repodir/dists/jessie/Release |cut -f1 -d:))

    sed -i ${linenoarray[0]}s/$orimd5/$curmd5/ $repodir/dists/jessie/Release
    sed -i ${linenoarray[0]}s/$orisize/$cursize/ $repodir/dists/jessie/Release
    sed -i ${linenoarray[1]}s/$orisha1/$cursha1/ $repodir/dists/jessie/Release
    sed -i ${linenoarray[1]}s/$orisize/$cursize/ $repodir/dists/jessie/Release
    sed -i ${linenoarray[2]}s/$orisha256/$cursha256/ $repodir/dists/jessie/Release
    sed -i ${linenoarray[2]}s/$orisize/$cursize/ $repodir/dists/jessie/Release

    wget --no-check-certificate -qO $repodir/dists/jessie/main/installer-amd64/current/images/udeb.list $MIRROR/dists/jessie/main/installer-amd64/current/images/udeb.list

    chmod -R 0644 $repodir/
  fi

  echo -e "Downloading optional deb pkg files...... [\033[32m ${MIRROR}/dists/jessie/main/binary-amd64/Packages.gz \033[0m]\n";

  for pkg in `echo "$1" |sed 's/,/\n/g'`
    do
    
      [[ -n "${OPTPKGS[$pkg"1"]}" ]] && {
        for subpkg in $(echo "${!OPTPKGS[@]}" |sed 's/\ /\n/g' |sort -n |grep "^$pkg")
          do
            cursubpkgfile="${OPTPKGS[$subpkg]}"
            [ -n "$cursubpkgfile" ] || continue

            cursubpkgfilepath=${cursubpkgfile%/*}
            mkdir -p $repodir/$cursubpkgfilepath
            cursubpkgfilename=${cursubpkgfile##*/}
            cursubpkgfilename2=$(echo $cursubpkgfilename|sed "s/\(+\|~\)/-/g")

            wget --no-check-certificate -qO $repodir/$cursubpkgfilepath/$cursubpkgfilename2 $MIRROR/$cursubpkgfile; \
            [[ "${OPTPKGS["fmt"$pkg]}" == "tar" ]] && ar x $repodir/$cursubpkgfilepath/$cursubpkgfilename2 data.tar.gz && tar xzf data.tar.gz && rm -rf data.tar.gz
            [[ "${OPTPKGS["fmt"$pkg]}" == "xz" ]] && ar x $repodir/$cursubpkgfilepath/$cursubpkgfilename2 data.tar.xz && xz -d data.tar.xz && tar xf data.tar && rm -rf data.tar

          done
            [[ -n "${OPTPKGS["bin"$pkg]}" ]] && mv -f /tmp/boot/${OPTPKGS["bin"$pkg]} /tmp/boot/${OPTPKGS["bin"$pkg]}2
            # [[ ! -f  /tmp/boot/${OPTPKGS["bin"$pkg]}2 ]] && echo 'Error! $1 SUPPORT ERROR.' && exit 1;
      }

    done

}
buildrepo libc,common,busybox,wgetssl;

PrepareDDessentials()也更強大,支持sharepoint和office365個人的302跳轉風格,強化《利用installnet制作一個云裝機packerpe》2中關于僅支持office365style相關方面功能 --- 其實sharepointstyle和office365 style也可自動公判斷,但是我不想折騰了。

UNZIP=''
DDURL=''
OFFICE365STYLE='0'
SHAREPOINTSTYLE='1'

function PrepareDDessentials(){

  if [[ -n "$tmpDDURL" ]]; then
    echo "$tmpDDURL" |grep -q '^http://\|^ftp://\|^https://';
    [[ $? -ne '0' ]] && echo 'No valid URL in the DD argument,Only support http://, ftp:// and https:// !' && exit 1;

    IMGHEADER="$(curl -Is "$tmpDDURL")";
    IMGTYPE="$(echo "$IMGHEADER" | grep -E -o '200|302')" || IMGTYPE='0';

    # [[ "$IMGTYPE" -ne '0' ]] && echo 'not a raw,tar,gunzip or 301/302 ref file, exit ... !' && exit 1 || {

      [[ "$IMGTYPE" == '200' ]] && IMGHEADERCHECKPASS2="$(echo "$IMGHEADER" |grep -E -o 'raw|qcow2|gzip|x-gzip')" && {
        [[ "$IMGTYPECHECKPASS2" == 'raw' ]] && UNZIP='0' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m raw \033[0m]";
        [[ "$IMGTYPECHECKPASS2" == 'qcow2' ]] && UNZIP='0' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m raw \033[0m]";
        [[ "$IMGTYPECHECKPASS2" == 'gzip' ]] && UNZIP='1' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m gzip \033[0m]";
        [[ "$IMGTYPECHECKPASS2" == 'x-gzip' ]] && UNZIP='1' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m x-gzip \033[0m]";
        [[ "$IMGTYPECHECKPASS2" == 'gunzip' ]] && UNZIP='2' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m gunzip \033[0m]";
      }

      [[ "$IMGTYPE" == '302' && "$OFFICE365STYLE" == '1' ]] && { \

        IMGHEADERCHECKPASS2="$(echo "$IMGHEADER" |grep 'Location: http'|sed 's/Location: //g')" && IMGHEADERCHECKPASS2=${IMGHEADERCHECKPASS2%$'\r'} && \
        IMGHEADERCHECKPASS3="$(curl -Is "$IMGHEADERCHECKPASS2" |grep 'content-location: http'|sed 's/content-location: //g')" && IMGHEADERCHECKPASS3=${IMGHEADERCHECKPASS3%$'\r'} && \

        IMGTYPECHECKPASS2="$(curl -Is "$IMGHEADERCHECKPASS3" | grep -E -o 'raw|qcow2|gzip|x-gzip|gunzip')" && {
          [[ "$IMGTYPECHECKPASS2" == 'raw' ]] && UNZIP='0' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m raw \033[0m]";
          [[ "$IMGTYPECHECKPASS2" == 'qcow2' ]] && UNZIP='0' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m raw \033[0m]";
          [[ "$IMGTYPECHECKPASS2" == 'gzip' ]] && UNZIP='1' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m gzip \033[0m]";
          [[ "$IMGTYPECHECKPASS2" == 'x-gzip' ]] && UNZIP='1' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m x-gzip \033[0m]";
          [[ "$IMGTYPECHECKPASS2" == 'gunzip' ]] && UNZIP='2' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m gunzip \033[0m]";
        }
      }



      [[ "$IMGTYPE" == '302' && "$SHAREPOINTSTYLE" == '1' ]] && { \

        IMGHEADERCHECKPASS2="$(echo "$IMGHEADER" |grep 'Location: http'|sed 's/Location: //g')" && IMGHEADERCHECKPASS2=${IMGHEADERCHECKPASS2%$'\r'} && \

        IMGTYPECHECKPASS2="$(curl -Is "$IMGHEADERCHECKPASS2" | grep -E -o 'raw|qcow2|gzip|x-gzip|gunzip')" && {
          [[ "$IMGTYPECHECKPASS2" == 'raw' ]] && UNZIP='0' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m raw \033[0m]";
          [[ "$IMGTYPECHECKPASS2" == 'qcow2' ]] && UNZIP='0' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m raw \033[0m]";
          [[ "$IMGTYPECHECKPASS2" == 'gzip' ]] && UNZIP='1' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m gzip \033[0m]";
          [[ "$IMGTYPECHECKPASS2" == 'x-gzip' ]] && UNZIP='1' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m x-gzip \033[0m]";
          [[ "$IMGTYPECHECKPASS2" == 'gunzip' ]] && UNZIP='2' && DDURL="$tmpDDURL" && sleep 3s && echo -en "[\033[32m gunzip \033[0m]";
        }
      }



      [[ "$UNZIP" == '' ]] && echo 'didnt got a unzip mode, exit ... !' && exit 1;
      [[ "$DDURL" == '' ]] && echo 'didnt got a ddurl, exit ... !' && exit 1;

      [[ "$IMGTYPE" == '0' ]] && echo 'not a raw,tar,gunzip or 301/302 ref file, exit ... !' && exit 1;
    # }

  else
    echo 'Please input vaild image URL! ';
    exit 1;
  fi

}
echo -e 'prepare DDessentials ......';
PrepareDDessentials;
sleep 3s

使用方法

中途提示備份,會給你30s上傳/tmp/boot/var/log/debian倉庫到onedrive或其它服務器創建鏡像,。

  [[ "$tmpINSTANTWITHOUTVNC" == '0' ]] &&  echo "finished, auto reboot after 30s...(if needed, you can press ctrl c to interrupt to bak the repodir:$repodir, then manually reboot to continue)";sleep 30s

preseed中的mirrorhost換成你的od上傳地址。

看完上述內容,你們掌握如何利用onedrive加packerpebuilder實現本地網絡統一裝機的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

徐汇区| 光泽县| 泊头市| 越西县| 舒兰市| 松阳县| 阜阳市| 全南县| 稷山县| 库尔勒市| 东宁县| 庆元县| 海宁市| 大连市| 中卫市| 冕宁县| 磴口县| 门源| 桑植县| 盘锦市| 大余县| 湘潭县| 汨罗市| 商河县| 穆棱市| 嘉荫县| 汉阴县| 海口市| 滁州市| 闻喜县| 景洪市| 莲花县| 油尖旺区| 安龙县| 新昌县| 松江区| 县级市| 孝昌县| 迭部县| 澄迈县| 汽车|