现在,我有一个简单的文件,每次打开 Gitpod(云环境)时都会运行。我正在制作一个文件,以便我可以通过 ngrok 访问它。但是,我需要一些包,比如 wget、unzip 和 neofetch(为了我的方便)。但它在不同的终端打开,我y每次都必须输入。有没有办法将 y 放入命令中,它会自动安装?
该文件的源代码:
#!/bin/bash
sudo apt update
sudo apt install wget unzip openssh-server neofetch -y
sudo service ssh start
echo "Set Password for Gitpod as gitpod"
sudo passwd gitpod
wget "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip"
unzip "ngrok-stable-linux-amd64.zip"
echo "I need your ngrok auth token. Enter it below."
read -p "ngrok authtoken:" authtoken
./ngrok authtoken $authtoken
echo "Authtoken activated, now activating server..."
./ngrok tcp 22
sudo apt install wget unzip openssh-server neofetch -y
我在这一行中输入正确吗?如果这可行,那么每当我获得云环境时,它都可以安装所有的 deps 并继续。
输出:不是答案,是输出。
我喜欢和使用的鱼壳的输出:
Welcome to fish, the friendly interactive shell
Type `help` for instructions on how to use fish
gitpod@ws-588be66f-373e-46f0-8342-5d39b8c863f4 /w/coder-lg-blog-codedoc (master)> sh .gitpod/ngrok.sh
Hit:1 https://download.docker.com/linux/ubuntu focal InRelease
Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:4 http://ppa.launchpad.net/git-core/ppa/ubuntu focal InRelease
Hit:5 https://deb.nodesource.com/node_16.x focal InRelease
Hit:6 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:7 https://apt.llvm.org/focal llvm-toolchain-focal InRelease
Hit:8 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
107 packages can be upgraded. Run 'apt list --upgradable' to see them.
.gitpod/ngrok.sh: 5: y: not found
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
是的,它是我博客的云 Gitpod 环境,我希望通过 ngrok 建立 SSH 隧道,但它说:
/repo > .gitpod/ngrok.sh: 5: y: 未找到
我怎样才能解决这个问题?mod删除了最后一个输出所以请不要删除这个!它主要是 Gitpod 终端的输出。