在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:wilsonmar/git-utilities开源软件地址:https://github.com/wilsonmar/git-utilities开源编程语言:Shell 45.6%开源软件介绍:This article explains the script that builds a Mac machine with "everything" needed by a professional developer. This is a "bootstrapping" script to enable you to more easily manage the complexity of competing stacks of components and their different versions. Java, Python, Node and their most popular add-ons are covered here. Logic in the script goes beyond what Homebrew does, and configures the component just installed:
TD;LR CustomizationThis bring DevSecOps-style "immutable architecture" to MacOS laptops. Immutability means replacing the whole machine instance instead of upgrading or repairing faulty components. Like many, you may have an AirPort Time Capsule to back up everything using the MacOS Time Machine app. However, as this person discovered,
This script helps you manage what you have installed so you can, but don't have to start from scratch. Target users of this script are those who configure new laptops for developers joining the organization, so each developer doesn't waste days installing everything one at a time (and doing it differently than colleagues). To do the above manually for each component would involve hours needlessly, and be error-prone. Technical techniques for the Bash shell scripting are described separtely at Bash scripting page in this website. How this worksThis script references a folder in your Home folder named git-utilities, It contains a configuration file named secrets.sh which you edit to specify what you want installed and run. The file's name is suffixed with ".sh" because it is run to establish variables for the script to reference. You don't run the file yourself. It is run by script mac-install-all.sh which you initiate within a Terminal command line.
Mac appsApps on Apple's App Store for Mac need to be installed manually. Popular apps include:
The brew "mas" manages Apple Store apps, but it only manages apps that have already been paid for. But mas does not install apps new to your Apple Store account. Java tools via Maven, AntApps added by specifying in JAVA_TOOLS are GUI apps. Most other Java dependencies are specified by manually added in each custom app's pom.xml file to specify what Maven downloads from the Maven Central online repository of installers at http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.dbunit%22 Popular in the Maven Repository are:
When using Gradle, insert file java-testng-gradle as a dependency to gradle working within Eclipse plug-in Build from source git://github.com/cbeust/testng.git using ./build-with-gradle TODO: The Python edition of this will insert specs such as this in pom.xml files. LoggingThe script outputs logs to a file. This is so that during runs, what appears on the command console are only what is relevant to debugging the current issue. At the end of the script, the log is shown in an editor to enable search through the whole log. Jenkins serverTo start the Jenkins server to a specified port:
The "&" puts the process in the background so that the script can continue running. The response is a bunch of lines ending with "INFO: Jenkins is fully up and running". Several other methods (which don't work now) are presented on the internet: This blog, on Dec 29, 2014 recommends sudo defaults write /Library/Preferences/org.jenkins-ci httpPort "$JENKINS_PORT" sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist The command "jenkins" above is actually a bash script that invokes Java: #!/bin/bash JAVA_HOME="$(/usr/libexec/java_home --version 1.8)" \ exec java -jar /usr/local/Cellar/jenkins/2.113/libexec/jenkins.war "$@" The code within "$(...)" is run to obtain the value. In this case, it's:
The link above is the folder where MacOS keeps the Java SDK. Java executables (java, javac, etc.) are in the bin folder below that location. The path to jenkins.war and jenkins-cli.war executable files are physcally at: ls /usr/local/opt/jenkins/libexec Mac Plist file for JenkinsInstead of specifying the port in the command, change the configuration file. On MacOS, services are defined by plist files containing XML, such as this for Jenkins server: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>homebrew.mxcl.jenkins</string> <key>ProgramArguments</key> <array> <string>/usr/libexec/java_home</string> <string>-v</string> <string>1.8</string> <string>--exec</string> <string>java</string> <string>-Dmail.smtp.starttls.enable=true</string> <string>-jar</string> <string>/usr/local/opt/jenkins/libexec/jenkins.war</string> <string>--httpListenAddress=127.0.0.1</string> <string>--httpPort=8080</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> The "1.8" is the version of Java, described below. The "httpPort=8080" default is customized using this variable in secrets.sh:
The above is file homebrew.mxcl.jenkins.plist within folder /usr/local/opt/jenkins installed by brew. The folder is a symlink created by brew to the physical path where brew installed it:
The "2.113" means that several versions of Jenkins can be installed side-by-side. This version number changes over time. So it is captured by command: JENKINS_VERSION=$(jenkins --version) # 2.113 The folder is actually a symlnk which points to the physical folder defined by: JENKINS_CONF="/usr/local/Cellar/Jenkins/$JENKINS_VERSION/homebrew.mxcl.jenkins.plist" The path is defined in a variable so simplify the sed command to make the change:
Jenkins GUI in browserThe command to view the server in the default internet browser (such as Safari, Chrome, etc.) is: open "http://localhost:$JENKINS_PORT" It's "http" and not "https" because a certificate has not been established yet. When executed the first time, Jenkins displays this screen: However, we don't want to open it from the command line script, but from a GUI automation script. Jenkins GUI automationThe script invokes a GUI automation script that opens the file mentioned on the web page above: /Users/wilsonmar/.jenkins/secrets/initialAdminPassword "/Users/wilsonmar" is represented by the environment variable named $HOME or ~ symbol, which would be different for you, with your own MacOS account name. Thus, the generic coding is: JENKINS_SECRET=$(<$HOME/.jenkins/secrets/initialAdminPassword) The file (and now $JENKINS_SECRET) contains a string in clear-text like "851ed535fd3249ab95a274d23242655c". We then call a GUI automation script to get that string to paste it in the box labeled "Administrator Password" based on the id "security-token" defined in this HTML: <input id="security-token" class="form-control" type="password" name="j_password"> This was determined by obtaining the outer HTML from Chrome Developer Tools. The call is: python tests/jenkins_secret_chrome.py chrome $JENKINS_PORT $JENKINS_SECRET We use Selenium Python because it reads and writes system environment variables. Use of Selenium and Python this way requires them to be installed before Jenkins and other web servers. Jenkins shutdown (kill)To shut down Jenkins, PID="ps -A | grep -m1 'jenkins' | awk '{print $1}'" fancy_echo "Shutting downn jenkins $PID ..." kill $PID The above is the automated approach to the manual on recommended by many blogs on the internet: Some say in Finder look for Applications -> Utilities -> Activity Monitor Others say use command: ps -el | grep jenkins Two lines would appear. One is the bash command to do the ps command. The PID desired is the one that lists the path used to invoke Jenkins, described above: /usr/bin/java -jar /usr/local/Cellar/jenkins/2.113/libexec/jenkins.war kill 2134 That is the equivalent of Windows command "taskkill /F /PID XXXX" There is also: sudo service jenkins stop Either way, the response expected is: INFO: JVM is terminating. Shutting down Winstone Python GUI AutomationIf the title is not found an error message like this appears on the console: File "tests/jenkins_secret_chrome.py", line 30, in assert "Jenkins [Jenkins]" in driver.title # bail out if not found. AssertionError Delay to viewSome put in a 5 second delay: time.sleep(5) Use of this feature requires a library to be specified at the top of the file: import sys Screen shot pictureSome also take a photo to "prove" that the result was achieved: driver.save_screenshot('jenkins_secret_chrome.py' +utc_offset_sec+ '.png') We put the name of the script file in the picture name to trace back to its origin. We put a time stamp in ISO 8601 format so that several png files sort by date. utc_offset_sec = time.altzone if time.localtime().tm_isdst else time.timezone datetime.datetime.now().replace(tzinfo=datetime.timezone(offset=utc_offset_sec)).isoformat() The long explanation is https://docs.python.org/2/library/datetime.html End of script NOTE:
driver.quit() means that someone watching the script execute would only see the web app's screen for a split second. We prefer to use id rather than name fields because the HTML standard states that id's are supposed to be unique in each web page. GroovyOther similar scripts (listed in "References" below) run http://groovy-lang.org/install.html Cloud SyncDropbox, OneDrive, Google Drive, Amazon Drive Eclips IDE plug-inshttp://download.eclipse.org/releases/juno Within Eclipse IDE, get a list of plugins at Help -> Install New Software -> Select a repo -> select a plugin -> go to More -> General Information -> Identifier eclipse -application org.eclipse.equinox.p2.director \ -destination d:/eclipse/ \ -profile SDKProfile \ -clean -purgeHistory \ -noSplash \ -repository http://download.eclipse.org/releases/juno/ \ -installIU org.eclipse.cdt.feature.group, \ org.eclipse.egit.feature.group "Equinox" is the runtime environment of Eclipse, which is the reference implementation of OSGI. Thus, Eclipse plugins are architectually the same as bundles in OSGI. Notice that there are different versions of Eclipse repositories, such as "juno". PROTIP: Although one can install several at once, do it one at a time to see if you can actually use each one. Some of them: org.eclipse.cdt.feature.group, \ org.eclipse.egit.feature.group, \ org.eclipse.cdt.sdk.feature.group, \ org.eclipse.linuxtools.cdt.libhover.feature.group, \ org.eclipse.wst.xml_ui.feature.feature.group, \ org.eclipse.wst.web_ui.feature.feature.group, \ org.eclipse.wst.jsdt.feature.feature.group, \ org.eclipse.php.sdk.feature.group, \ org.eclipse.rap.tooling.feature.group, \ org.eclipse.linuxtools.cdt.libhover.devhelp.feature.feature.group, \ org.eclipse.linuxtools.valgrind.feature.group, \ NOTE: A feature group is a list of plugins and other features which can be understood as a logical separate project unit for the updates manager and for the build process. Scape for Fonts in GitHubSome developers have not put their stuff from GitHub into Homebrew. So we need to read (scrape) the website and see what is listed, then grab the text and URL to download. Such is the situation with font files at https://github.com/adobe-fonts/source-code-pro/releases/tag/variable-fonts The two files desired downloaded using the curl command are:
The files are downloaded into where MacOS holds fonts available to all users: /Library/Fonts/ ITerm2 can make use of these font files. Other lists of Mac programs
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论