Skip to content

Commit

Permalink
Merge branch 'master' into update-for-history
Browse files Browse the repository at this point in the history
  • Loading branch information
shunk031 authored Apr 27, 2024
2 parents 70c3bfb + fa16dc6 commit 8499062
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 8 deletions.
6 changes: 3 additions & 3 deletions home/.chezmoiexternal.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ template "chezmoiexternal.d/common.yaml" . }}
{{ template "chezmoiexternal.d/common.yaml.tmpl" . }}
{{ if eq .system "server" -}}
{{ template "chezmoiexternal.d/server.yaml" . }}
{{ template "chezmoiexternal.d/server.yaml.tmpl" . }}
{{ end -}}
{{ if (or (eq .chezmoi.os "darwin") (eq .system "client")) -}}
{{ template "chezmoiexternal.d/macos_client.yaml" . -}}
{{ template "chezmoiexternal.d/macos_client.yaml.tmpl" . -}}
{{ end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{ if eq .chezmoi.os "linux" -}}
{{ if eq .chezmoi.osRelease.idLike "debian" -}}
{{ if eq .system "server" -}}
{{ include "../install/ubuntu/server/ssh_server.sh" }}
{{ end -}}
{{ end -}}
{{ end -}}
14 changes: 13 additions & 1 deletion home/dot_local/bin/server/aliases.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
#!/usr/bin/env bash

#
# Use nvidia-smi alternative command
#
alias ns="watch -n 4 -cd nvinfo"
alias ls="eza --long --group --header --binary --time-style=long-iso --icons"

#
# Use eza or exa for ls command
#
if command -v "eza" >/dev/null 2>&1; then
my_ls="eza"
else
my_ls="exa"
fi
alias ls="${my_ls} --long --group --header --binary --time-style=long-iso --icons"
21 changes: 17 additions & 4 deletions install/ubuntu/common/eza.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,24 @@ if [ "${DOTFILES_DEBUG:-}" ]; then
set -x
fi

function apt_install_eza() {
sudo apt install -y eza
}

function apt_install_exa() {
sudo apt install -y exa
}

function install_eza() {
wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo tee /etc/apt/trusted.gpg.d/gierens.asc
echo "deb http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
sudo apt-get update
sudo apt-get install -y eza
sudo mkdir -p /etc/apt/keyrings
wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --yes --dearmor -o /etc/apt/keyrings/gierens.gpg
echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
sudo chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list
sudo apt update

if ! apt_install_eza; then
apt_install_exa
fi
}

function uninstall_eza() {
Expand Down
46 changes: 46 additions & 0 deletions install/ubuntu/server/ssh_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

set -Eeuo pipefail

if [ "${DOTFILES_DEBUG:-}" ]; then
set -x
fi

function install_openssh_server() {
# install openssh-server
apt-get update && apt-get install --no-install-recommends -y vim openssh-server
}

function setup_sshd() {
mkdir -p /var/run/sshd
mkdir -p /root/.ssh

sed -i 's/^#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config &&
sed -i 's/^#Port 22/Port 22/' /etc/ssh/sshd_config &&
sed -i 's/^#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/' /etc/ssh/sshd_config &&
sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config &&
sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd

# check the /etc/ssh/sshd_config
/usr/sbin/sshd -t

# create .ssh/authorized_keys if not exists
touch ~/.ssh/authorized_keys
}

function run_sshd() {
# run sshd
/usr/sbin/sshd
}

function main() {
install_openssh_server
setup_sshd
run_sshd
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
if [ -f "/.dockerenv" ]; then
main
fi
fi

0 comments on commit 8499062

Please sign in to comment.