u
This commit is contained in:
parent
25632ab024
commit
cbe9d7ef85
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "---------------------------------------------"
|
echo "---------------------------------------------"
|
||||||
echo "User Name (leave blank for no change as $(git config --get user.name)"
|
echo "Set [user name] or leave blank for unchanged \"$(git config --get user.name)\""
|
||||||
read -p "***:: " UserName
|
read -p "***:: " UserName
|
||||||
if [ $UserName ]
|
if [ $UserName ]
|
||||||
then
|
then
|
||||||
@ -10,7 +10,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "---------------------------------------------"
|
echo "---------------------------------------------"
|
||||||
echo "User Email (leave blank for no change as $(git config --get user.email))"
|
echo "User Email (leave blank for unchanged $(git config --get user.email))"
|
||||||
read -p "***:: " UserEmail
|
read -p "***:: " UserEmail
|
||||||
if [ $UserEmail ]
|
if [ $UserEmail ]
|
||||||
then
|
then
|
||||||
@ -20,7 +20,7 @@ fi
|
|||||||
|
|
||||||
echo "---------------------------------------------"
|
echo "---------------------------------------------"
|
||||||
echo "如果 git 远程服务器的 ssl 证书过期,或者使用了自颁发的证书,连接时会出现验证错误 Cannot verify local issuer"
|
echo "如果 git 远程服务器的 ssl 证书过期,或者使用了自颁发的证书,连接时会出现验证错误 Cannot verify local issuer"
|
||||||
echo "Verify ssl? (true or false, blank for no change as $(git config --get http.sslVerify))"
|
echo "Verify ssl? (true, false, or leave blank for unchanged $(git config --get http.sslVerify))"
|
||||||
read -p "***:: " HttpSslVerify
|
read -p "***:: " HttpSslVerify
|
||||||
if [ $HttpSslVerify ]
|
if [ $HttpSslVerify ]
|
||||||
then
|
then
|
||||||
@ -29,7 +29,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "---------------------------------------------"
|
echo "---------------------------------------------"
|
||||||
echo "Store credential in cache or store? (leave blank for no change as $(git config --get credential.helper))"
|
echo "Store credential in [cache] or [store]? (leave blank for unchanged $(git config --get credential.helper))"
|
||||||
read -p "***:: " CredentialHelper
|
read -p "***:: " CredentialHelper
|
||||||
if [ $CredentialHelper ]
|
if [ $CredentialHelper ]
|
||||||
then
|
then
|
||||||
@ -38,7 +38,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "---------------------------------------------"
|
echo "---------------------------------------------"
|
||||||
echo "Store pull rebase to true or false? (leave blank for no change as $(git config --get pull.rebase))"
|
echo "Store pull rebase to [true] or [false]? (leave blank for unchanged $(git config --get pull.rebase))"
|
||||||
read -p "***:: " PullRebase
|
read -p "***:: " PullRebase
|
||||||
if [ $PullRebase ]
|
if [ $PullRebase ]
|
||||||
then
|
then
|
||||||
@ -47,7 +47,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "---------------------------------------------"
|
echo "---------------------------------------------"
|
||||||
echo "Set [path to global gitignore file] (leave blank for no change as $(git config --get core.excludesfile))"
|
echo "Set [path to global gitignore file] or leave blank for unchanged $(git config --get core.excludesfile)"
|
||||||
read -p "***:: " ExcludesFile
|
read -p "***:: " ExcludesFile
|
||||||
if [ $ExcludesFile ]
|
if [ $ExcludesFile ]
|
||||||
then
|
then
|
||||||
@ -58,7 +58,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "---------------------------------------------"
|
echo "---------------------------------------------"
|
||||||
echo "Set default branch since git 2.28 to master or main? (leave blank for no change as $(git config --get init.defaultbranch))"
|
echo "Set default branch since git 2.28 to master or main? (leave blank for unchanged $(git config --get init.defaultbranch))"
|
||||||
read -p "***:: " DefaultBranch
|
read -p "***:: " DefaultBranch
|
||||||
if [ $DefaultBranch ]
|
if [ $DefaultBranch ]
|
||||||
then
|
then
|
||||||
@ -67,7 +67,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "---------------------------------------------"
|
echo "---------------------------------------------"
|
||||||
echo "Set postBuffer size? Suggesting 157286400 (leave blank for no change as $(git config --get http.postBuffer))"
|
echo "Set postBuffer size? Suggesting 157286400 (leave blank for unchanged $(git config --get http.postBuffer))"
|
||||||
read -p "***:: " PostBufferSize
|
read -p "***:: " PostBufferSize
|
||||||
if [ $PostBufferSize ]
|
if [ $PostBufferSize ]
|
||||||
then
|
then
|
||||||
|
|||||||
16
mac-create-vdisk.plist
Normal file
16
mac-create-vdisk.plist
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?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>mac-create-vdisk</string>
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>/etc/mac-create-vdisk.sh</string>
|
||||||
|
</array>
|
||||||
|
<key>RunAtLoad</key>
|
||||||
|
<true/>
|
||||||
|
<key>KeepAlive</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
18
mac-create-vdisk.sh
Normal file
18
mac-create-vdisk.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DISKNAME=vdisk
|
||||||
|
DISKSIZE=33554432 # 磁盘扇区数,每个扇区大小是 512 字节,n*1024*1024*1024/512 = n Gigabytes. Do NOT set the formula to DISKSIZE.
|
||||||
|
# 虚拟磁盘并不是一创建就把内存空间划走,而是等到真正写入了虚拟磁盘的时候,才会使用对应的内存空间,所以给虚拟磁盘分配大一点的空间是没有问题的
|
||||||
|
|
||||||
|
if [ -d /Volumes/$DISKNAME ]; then
|
||||||
|
echo 'Found /Volumes/$DISKNAME!'
|
||||||
|
else
|
||||||
|
DISKID=$(hdid -nomount ram://$DISKSIZE)
|
||||||
|
diskutil apfs create ${DISKID} $DISKNAME
|
||||||
|
fi
|
||||||
|
|
||||||
|
# copy this script to some public folder, e.g. `sudo cp this-script.sh /etc/`, because in my test, it doesn't work in /Users/...
|
||||||
|
# copy the corresponding plist file to /Library/LaunchDaemons/,
|
||||||
|
# optionally run `sudo launchctl load /Library/LaunchDaemons/my-launch-file.plist` immediately for test.
|
||||||
@ -69,9 +69,6 @@ if [ -d "$HomePath" ]; then
|
|||||||
# 由 root 指定新用户而创建的配置文件的 owner 是 root,而不是新用户,导致新用户无法读取该文件而密钥登录失败,因此要重设 owner。
|
# 由 root 指定新用户而创建的配置文件的 owner 是 root,而不是新用户,导致新用户无法读取该文件而密钥登录失败,因此要重设 owner。
|
||||||
chown "$TheUser:$TheUser" "$HomePath/.ssh"
|
chown "$TheUser:$TheUser" "$HomePath/.ssh"
|
||||||
fi
|
fi
|
||||||
if [ -f "$HomePath/.ssh/authorized_keys" ] || [ -L "$HomePath/.ssh/authorized_keys" ]; then
|
|
||||||
mv "$HomePath/.ssh/authorized_keys" "$HomePath/.ssh/authorized_keys.backup-$(date -u +%Y%m%dT%H%M%Sutc)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "::*** Append or link or omit [[$HomePath/.ssh/authorized_keys]] to config ssh server? [a] for append, [l] for link, [anything else] for omit:"
|
echo "::*** Append or link or omit [[$HomePath/.ssh/authorized_keys]] to config ssh server? [a] for append, [l] for link, [anything else] for omit:"
|
||||||
read -p "***:: " AuthorizedKeys
|
read -p "***:: " AuthorizedKeys
|
||||||
@ -84,9 +81,16 @@ if [ -d "$HomePath" ]; then
|
|||||||
echo "--- Copying [[$NIXHOME/authorized_keys]] to [[$HomePath/.ssh/authorized_keys]] ..."
|
echo "--- Copying [[$NIXHOME/authorized_keys]] to [[$HomePath/.ssh/authorized_keys]] ..."
|
||||||
cat "$NIXHOME/.ssh/authorized_keys" >> "$HomePath/.ssh/authorized_keys"
|
cat "$NIXHOME/.ssh/authorized_keys" >> "$HomePath/.ssh/authorized_keys"
|
||||||
chmod 600 "$HomePath/.ssh/authorized_keys"
|
chmod 600 "$HomePath/.ssh/authorized_keys"
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
if [ -f "$HomePath/.ssh/authorized_keys" ] || [ -L "$HomePath/.ssh/authorized_keys" ]; then
|
||||||
|
mv "$HomePath/.ssh/authorized_keys" "$HomePath/.ssh/authorized_keys.backup-$(date -u +%Y%m%dT%H%M%Sutc)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
popd
|
popd
|
||||||
|
|||||||
@ -125,7 +125,7 @@ esac
|
|||||||
# others:
|
# others:
|
||||||
# \w shows absolute path, \W shows current folder.
|
# \w shows absolute path, \W shows current folder.
|
||||||
if [ "$color_prompt" = yes ]; then
|
if [ "$color_prompt" = yes ]; then
|
||||||
PS1='[\[\033[07;32m\]\t\[\033[00m\]#\[\033[07;35m\]\u\[\033[00m\]@\[\033[07;31m\]\h|$(uname)|$(uname -m)\[\033[00m\]::\[\033[07;34m\]\w\[\033[00m\]] '
|
PS1='[\[\033[07;32m\]\t\[\033[00m\]#\[\033[07;35m\]\u\[\033[00m\]@\[\033[07;31m\]\h=$(uname)=$(uname -m)\[\033[00m\]::\[\033[07;34m\]\w\[\033[00m\]] '
|
||||||
else
|
else
|
||||||
PS1='[\t#\u@\h($(uname)-$(uname -m)):\w] ' # \w shows absolute path, \W shows current folder.
|
PS1='[\t#\u@\h($(uname)-$(uname -m)):\w] ' # \w shows absolute path, \W shows current folder.
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user