我正在使用Linode部署Ubuntu 18.04LTS VM。引导后执行以下脚本(Linode称其为“堆栈脚本”)。它的工作原理包括安装Java。 SCP命令似乎无效。如果我在启动的VM上手动执行命令,它会像超级按钮一样工作。有什么问题吗?
#!/bin/bash
#store ip
export nodeManagerIp=999.999.99.999
#install tools
sudo apt-get update
sudo apt-get --assume-yes install sshpass
sudo apt-get --assume-yes install openjdk-11-jre-headless
#add node manager to known hosts
ssh-keyscan $nodeManagerIp >> ~/.ssh/known_hosts
#get resources
sshpass -p 'thePassword' scp root@$nodeManagerIp:/opt/* /opt/
##start server##
#as many threads as cores
threads=$(cat /proc/cpuinfo | grep processor | wc -l)
#start server
java -cp app-1.0.0-SNAPSHOT-jar-with-dependencies.jar de.wipj.application.Server threads=$threads
这是日志。我以超级用户身份运行了脚本。问题出在ssh-keyscan。当我在VM上手动执行该行时,为什么它能正常工作?
ding debian:Secure_Global_CA.pem
Adding debian:AffirmTrust_Premium.pem
Adding debian:USERTrust_RSA_Certification_Authority.pem
Adding debian:OISTE_WISeKey_Global_Root_GB_CA.pem
Adding debian:SSL.com_EV_Root_Certification_Authority_ECC.pem
Adding debian:GDCA_TrustAUTH_R5_ROOT.pem
Adding debian:Certum_Trusted_Network_CA.pem
Adding debian:AffirmTrust_Premium_ECC.pem
Adding debian:ePKI_Root_Certification_Authority.pem
Adding debian:QuoVadis_Root_CA_2.pem
Adding debian:USERTrust_ECC_Certification_Authority.pem
Adding debian:TWCA_Root_Certification_Authority.pem
Adding debian:COMODO_RSA_Certification_Authority.pem
Adding debian:GlobalSign_Root_CA_-_R3.pem
Adding debian:D-TRUST_Root_Class_3_CA_2_2009.pem
done.
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for systemd (237-3ubuntu10.21) ...
Processing triggers for ca-certificates (20180409) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
done.
+ sudo ssh-keyscan 999.999.99.999
/root/StackScript: line 13: /root/.ssh/known_hosts: No such file or directory
+ sudo sshpass -p thePassword scp 'root@999.999.99.999:/opt/*' /opt/
++ wc -l
++ grep processor
++ cat /proc/cpuinfo
+ export threads=1
+ threads=1
+ sudo java -cp /opt/app-1.0.0-SNAPSHOT-jar-with-dependencies.jar de.wipj.application.Server threads=5
Error: Could not find or load main class de.wipj.application.Server
Caused by: java.lang.ClassNotFoundException: de.wimj.application.Server
答案 0 :(得分:0)
从错误消息中:您在initrd中没有根目录。
在initrd内部,我希望通过export HOME=/
来解决此问题。现在您有了家。从好的角度来看,确保/ etc / password在initrd中具有root的根目录是一个好主意。