简体   繁体   English

自动化Linux软件安装

[英]Automate Linux software installations

I have a set of steps I follow in Linux which are as follows : 我在Linux中遵循以下一组步骤:

  1. Unzip a folder located at path /home/xyzuser/temp/File.zip to /home/xyzuser/source/ 将位于/home/xyzuser/temp/File.zip路径的文件夹解压缩到/ home / xyzuser / source /
  2. I then navigate to source using "cd /home/xyzuser/source/File" 然后,我使用“ cd / home / xyzuser / source / File”导航到源
  3. I find the listing of folders here using "find . -type d > hierarchy.txt" 我在这里找到文件夹的列表,使用“查找。-type d> architecture.txt”
  4. Remove a few directories in hierarchy.txt that are more than 5 folders deep . 删除hierarchy.txt中几个深度超过5个文件夹的目录。

    For example , if there is /level1/level2/level3/level4/level5/thisShouldBeRemoved , I manually delete this entry from the hierarchy.txt file 例如,如果存在/ level1 / level2 / level3 / level4 / level5 / thisShouldBeRemoved,那么我将手动从architecture.txt文件中删除此条目。

  5. Now copy a third python file from /home/xyzuser/temp/ to /home/xyzuser/source/File. 现在,将第三个python文件从/ home / xyzuser / temp /复制到/ home / xyzuser / source / File。 I make a few changes in this Python file and run it. 我在此Python文件中进行了一些更改并运行它。

  6. Then I issue a command to execute a 3rd party tool in the command line. 然后,我发出命令以在命令行中执行第三方工具。

    I worked with Java and don't really see how to automate this in Java. 我曾经使用过Java,但是并没有真正看到如何在Java中实现自动化。 But I feel shell , Perl or Python would help develop a single script which I can run to automate this entire process. 但是我觉得shell,Perl或Python将有助于开发一个脚本,我可以运行该脚本来自动化整个过程。 Can anyone give me a direction where I should begin exploring to start this stuff. 任何人都可以给我一个方向,让我开始探索以开始这些工作。 Is there any way of packaging the above Linux commands I give in the terminal and running them at once? 有什么办法可以打包我在终端中给出的上述Linux命令并立即运行它们?

read manual for unzip, cd, cp, mv for all other steps 阅读手册以了解解压缩,cd,cp,mv的所有其他步骤

for step 4 you can use the following code 对于步骤4,您可以使用以下代码

    for line in $(find . -type d)
        do
            levels=`echo $line|grep -o "/"|wc -l `
            if [ $levels -le 5 ] then 
                echo $line >> hierarchy.txt
            fi
        done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM