我正在通过ansible-playbook自动安装圣人。因为我需要运行两个shell脚本。 下面是第一个shell脚本的样子:如何将密码作为参数传递给shell脚本
#!/bin/bash
# Creating Sage notebook
dir="/root/.sage/sage_notebook.sagenb"
screen -S "Sage_Server" sage -c 'notebook(interface="", directory=$dir, port=80, accounts=true)'
这是第二个shell脚本代码:
#!/bin/bash
# Creating Sage inotebook
address=$(hostname --ip-address)
sage -c "inotebook(interface=" "'$address'" ",port=80,accounts=true)"
这是剧本的样子:
---
- hosts: localhost
remote_user: root
tasks:
- name : update system
apt : update_cache=yes
- name : install m4
apt : name=m4 state=present
- name : install build-essential
apt : name=build-essential state=present
- name : install gcc
apt : name=gcc state=present
- name : install gfortran
apt : name=gfortran state=present
- name : install libssl-dev
apt : name=libssl-dev state=present
- name : install python-software-properties
apt : name=python-software-properties state=present
- name : add sage ppa repo
apt_repository: repo='ppa:aims/sagemath'
- name : update system
apt : update_cache=yes
- name : install dvipng
apt : name=dvipng state=present
- name : install sage binary
apt : name=sagemath-upstream-binary state=present
- name : invoke create_sagenb script
command: /usr/bin/screen -d -m sudo /root/databases-and-datamining-iiith/python-scripts/create_sagenb -i -y
- name : invoke start_sage script
command: /usr/bin/screen -d -m sudo /root/databases-and-datamining-iiith/python-scripts/start_sage -i -y
现在,当我运行第一个脚本,它会要求一个新的可能是任何东西的圣人密码。但是我无法从剧本中传递密码。 不过,如果我做
ps -ef | grep sh
我可以看到脚本运行,但圣人服务没有运行。 它需要密码才能启动服务。
任何人都可以请告诉我如何通过命令将密码作为参数提供给shell脚本。
用于将密码传递给shell脚本的技术与用于在脚中拍摄自己的技巧相同。你避免它。没有引入安全漏洞就没有办法做到这一点。 –