未加星标

Moving home - updates to vcsh usage

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二03 | 时间 2019 | 作者 红领巾 ] 0人收藏点击收藏

A while back I switched tovcsh. I’ve written afew articles on using it but since then I’ve migrated machines a number of times.

The big issue I’ve found is having to manually install software on each machine. There are things my scripts depend on and things I just expect to have and manually creating them each time is annoying.

So the solution obviously is a script. It’s actually used all the time as I might create new dependencies or find new tools I need so I’d want that installed on all machines. So it runs in my ~/.zlogin file and by using a local stamp file (unlike forthird-pary sources) it reminds me periodically to run update now .

It first updates itself, it uses mr to update all my vim repositories, and then mostly uses native packaging tools to install software.

Switching to version control for home dirs was a lot of the battle, but getting the tools and things I need on the machines has been the next one. As it stands I can now pretty quickly get up to speed on a new machine in just a few minutes. It would be nice to have something where I could go, curl https://phrye.com/HOME | bash instead of having to remember the initial vcsh commands but that’s a further project.

#!/bin/bash set -e stamp_dir=~/.config/update stamp_file=~/.config/update/.last-update.stamp if [[ ! -d $stamp_dir ]]; then mkdir -p $stamp_dir fi do_update() { # Update homedir. if [[ "$1" != "vcsh-update-done" ]]; then vcsh pull exec "$0" now vcsh-update-done fi # Update vim modules. cd ~/.vim mr update # Update system. kernel=$(uname -v) echo "Running specific steps for '$kernel'." case "$kernel" in FreeBSD*) makewhatis ~/.config/home-man if [ ! -f /usr/local/go/bin/go ]; then sudo pkg install go fi for pkg in python3 py36-sqlite3 gsed bind-tools go awscli; do if ! pkg list $pkg > /dev/null; then pkg install $pkg fi done ;; *Ubuntu*) if [[ ! -d /var/lib/slack ]]; then if [[ -d /etc/sudoers.d && ! -f "/etc/sudoers.d/$USER" ]]; then echo "$USER ALL=(ALL) NOPASSWD: ALL" \ | sudo -p "Please enter password to configure sudo: " \ tee "/etc/sudoers.d/$USER" > /dev/null fi sudo -p "Please enter password to install packages: " \ apt install vim-nox unzip wget tree gpg pwgen fortune \ perl-doc bc shellcheck yamllint clang-tidy \ cppcheck flawfinder gitlint lua-check \ python3-flake8 pylint3 screen python3-defusedxml go_tar=go1.10.3.linux-amd64.tar.gz go_tar_dir=$HOME/.config/update if [[ ! -d "$go_tar_dir" ]]; then mkdir "$go_tar_dir" fi if [[ ! -f "$go_tar_dir/$go_tar" ]]; then wget --quiet -O "$go_tar_dir/$go_tar" -c https://dl.google.com/go/$go_tar if [[ -d /usr/local/go ]]; then sudo -p "Please enter password to remove old go installation: " \ rm -rf /usr/local/go fi fi if [[ ! -d /usr/local/go ]]; then echo "Installing new go version." sudo tar -C /usr/local -xzf "$go_tar_dir/$go_tar" export PATH=${PATH}:/usr/local/go export GOPATH=$HOME/src/go export KEVIN_GOWARN=1 fi fi ;; esac # If homebrew exists; update it too. if [[ -f /Users/kevin/Homebrew/bin/brew ]]; then brew update brew upgrade fi if [[ "$KEVIN_GOWARN" == 1 ]]; then cat << EOF Run the following in each currently open shell (or just log out and log in again): export PATH=$PATH export GOPATH=$GOPATH EOF fi touch $stamp_file } do_check() { update_required=false if [[ ! -f $stamp_file ]]; then update_required=true else if [[ $0 -nt $stamp_file ]]; then update_required=true fi if find $stamp_file -mtime +21 | grep -q stamp; then update_required=true fi fi if $update_required; then echo "INFO: Need to run 'update now' to update home dir." fi } do_usage() { echo "$0 [now|check]" } case "$1" in up|update|now) do_update "$2" ;; check|"") do_check ;; *) do_usage ;; esac

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

分页:12
转载请注明
本文标题:Moving home - updates to vcsh usage
本站链接:https://www.codesec.net/view/628610.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(24)