AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1413832
Accepted
Eric Chang
Eric Chang
Asked: 2022-06-14 06:09:27 +0800 CST2022-06-14 06:09:27 +0800 CST 2022-06-14 06:09:27 +0800 CST

如何使用交互式部分自动重启?

  • 772

自动安装与自定义用户数据完美运行,但安装完成后不会自动重启。

我在https://ubuntu.com/server/docs/install/autoinstall-reference中找不到有关重新启动的文档

我还在这里找到一篇文章http://junyelee.blogspot.com/2021/05/subiquity.html

# use interactive-sections to avoid an automatic reboot

这是我的用户数据

#cloud-config
autoinstall:
  ### config storage and network manually
  interactive-sections:
    - storage
  # Swapfile on root volume
  swap:
    swap: 16GB
  late-commands:
    - curtin in-target --target=/target -- apt-get --purge -y --quiet=2 remove byobu
    - curtin in-target --target=/target -- apt-get install -y git wget curl rsync net-tools ssh ubuntu-desktop plymouth-theme-ubuntu-logo grub-gfxpayload-lists mailutils
    - curtin in-target --target=/target -- hostnamectl set-hostname ubuntu-jammy.abc.com
  # Write a script that can take care of some post install setup "late-commands" cannot be interactive unfortunately"
    - |
      cat <<EOF | sudo tee /target/etc/finish-install-setup.sh
      #!/usr/bin/env bash
      echo *************************
      echo ****  Finish Setup   ****
      echo *************************
      echo 'Enter the hostname for this system: '
      read NEW_HOSTNAME
      hostnamectl set-hostname \${NEW_HOSTNAME}
      echo
      echo 'Enter the timezone for this system: '
      echo 'Asia/Taipei'
      read NEW_TIMEZONE
      timedatectl set-timezone \${NEW_TIMEZONE}
      echo *************************
      echo
      echo *************************
      echo 'Restarting to finish ...'
      shutdown -r 3
      EOF
    - curtin in-target --target /target chmod 744 /etc/finish-install-setup.sh
  apt:
    disable_components: []
    geoip: true
    preserve_sources_list: false
    primary:
    - arches:
      - amd64
      - i386
      uri: http://free.nchc.org.tw/ubuntu
    - arches:
      - default
      uri: http://ports.ubuntu.com/ubuntu-ports
  drivers:
    install: false
  identity:
    hostname: ubuntu-jammy
    password: somesupersecretpasswordhere
    realname: administrator
    username: administrator
  kernel:
    package: linux-generic
  keyboard:
    layout: us
    toggle: null
    variant: ''
  locale: en_US.UTF-8
  network:
    ethernets:
      ens18:
        dhcp4: true
    version: 2
  ssh:
    allow-pw: true
    authorized-keys: []
    install-server: true
  ### user-data , commands run during first boot
  user-data:
    runcmd:
      - rm -rf  /usr/bin/python
      - ln -s /usr/bin/python3.10 usr/bin/python
      - wget https://download.nomachine.com/download/7.8/Linux/nomachine_7.8.2_1_amd64.deb -O /opt/nomachine.deb
      - dpkg -i /opt/nomachine.deb
      #- /etc/finish-install-setup.sh
  version: 1

我必须在最后按回车键重新启动机器,我认为这不是一个好的“自动化”。

但是我需要手动配置存储布局,有没有安装完成后强制重启的解决方案?

automation
  • 1 1 个回答
  • 92 Views

1 个回答

  • Voted
  1. Best Answer
    Andrew Lowther
    2022-06-14T14:35:06+08:002022-06-14T14:35:06+08:00

    如果您指定任何interactive-sections,则安装程序(subiquity)认为安装是“交互式的”。如果安装是“交互式”的,那么安装程序将等待用户在安装完成后单击重新启动。

    无论如何,重新启动的简单方法是使用late-commands调用/sbin/reboot. 缺点是安装程序无法完成,之后执行的任何安装步骤late-commands都不会发生。我相信唯一会被跳过的步骤是将安装程序日志复制到已安装的系统中。

    #cloud-config
    autoinstall:
      late-commands:
        - |
          /sbin/reboot
    

    一个更笨拙的方法是模拟重新启动点击。客户端subiquity进程使用套接字 at将此事件传递给服务器subiquity/run/subiquity/socket进程。这是一个late-command模拟客户端通信的示例,因此服务器认为用户已请求重新启动。在此示例中,curl进程将阻塞,这就是为什么它在后台使用screen.

    #cloud-config
    autoinstall:
      late-commands:
        - |
          screen -dmS reboot curl --unix-socket /run/subiquity/socket -X POST http://a/shutdown?mode=%22REBOOT%22 --header "Content-Type:application/octet-stream"
          true
    

    笔记

    我使用 Ubuntu 22.04 ( subiquity 22.04.2)进行了测试

    • 0

相关问题

  • 在 ubuntu 服务器上使用 gvfs 或其他自动挂载程序?[关闭]

  • 自动保存特定 URL 的代理

  • 方便地在 Apple 和 PC 键盘之间切换(交换 Windows 和 Alt 键)

  • Mac OS X Automator 的替代品?

  • 我如何参与 Ubuntu 的测试和 QA?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve