Added pm-task upgrade.
This commit is contained in:
86
after-setup
Executable file
86
after-setup
Executable file
@@ -0,0 +1,86 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 1. Function to set up dir colors.
|
||||||
|
run_colourful_console() {
|
||||||
|
# Download the 256 colors dark theme.
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/seebi/dircolors-solarized/master/dircolors.256dark -o $HOME/.dircolors
|
||||||
|
|
||||||
|
# Create directory for vim colors if it doesn't exist.
|
||||||
|
mkdir -p $HOME/.vim/colors
|
||||||
|
|
||||||
|
# Download jellybeans theme for vim.
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/nanotech/jellybeans.vim/master/colors/jellybeans.vim -o $HOME/.vim/colors/jellybeans.vim
|
||||||
|
|
||||||
|
# Add or update .vimrc to set the colorscheme to jellybeans.
|
||||||
|
if [ ! -f "$HOME/.vimrc" ]; then
|
||||||
|
cat <<EOF > $HOME/.vimrc
|
||||||
|
syntax on
|
||||||
|
set tabstop=4
|
||||||
|
set softtabstop=4
|
||||||
|
set shiftwidth=4
|
||||||
|
set expandtab
|
||||||
|
set background=dark
|
||||||
|
colorscheme jellybeans
|
||||||
|
EOF
|
||||||
|
echo "Created .vimrc with jellybeans colorscheme."
|
||||||
|
else
|
||||||
|
sed -i '/^colorscheme/d' $HOME/.vimrc
|
||||||
|
echo "colorscheme jellybeans" >> $HOME/.vimrc
|
||||||
|
echo "Updated .vimrc with jellybeans colorscheme."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# 2. Function to generate commands to update SSHD config.
|
||||||
|
run_generate_sshd_commands() {
|
||||||
|
echo 'sudo sed -i "/#TCPKeepAlive yes/c\TCPKeepAlive no" /etc/ssh/sshd_config'
|
||||||
|
echo 'sudo sed -i "/^ClientAliveInterval/c\ClientAliveInterval 30" /etc/ssh/sshd_config'
|
||||||
|
echo 'sudo sed -i "/^ClientAliveCountMax/c\ClientAliveCountMax 300" /etc/ssh/sshd_config'
|
||||||
|
echo 'sudo systemctl restart sshd'
|
||||||
|
}
|
||||||
|
|
||||||
|
# 3. Function to set up tmux with tpm and a custom configuration.
|
||||||
|
run_setup_tmux() {
|
||||||
|
|
||||||
|
if ! command -v git &> /dev/null || ! command -v tmux &> /dev/null; then
|
||||||
|
echo "Please install git and tmux before running this task."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clone tpm if it's not already cloned
|
||||||
|
TPM_DIR="$HOME/.tmux/plugins/tpm"
|
||||||
|
if [ ! -d "$TPM_DIR" ]; then
|
||||||
|
git clone https://github.com/tmux-plugins/tpm.git $TPM_DIR
|
||||||
|
echo "Cloned tpm into $TPM_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the absolute path to the directory containing this bash script
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# Copy _tmux.conf to .tmux.conf in the user's home directory
|
||||||
|
cp "$SCRIPT_DIR/templates/_tmux.conf" $HOME/.tmux.conf
|
||||||
|
echo "Copied $SCRIPT_DIR/templates/_tmux.conf to $HOME/.tmux.conf"
|
||||||
|
echo "Now start tmux and press prefix + I to install the plugins."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tasks menu
|
||||||
|
echo "Select a task:"
|
||||||
|
echo "1. Colourful Console"
|
||||||
|
echo "2. Generate Commands to update SSHD config"
|
||||||
|
echo "3. Setup tmux"
|
||||||
|
read choice
|
||||||
|
|
||||||
|
case $choice in
|
||||||
|
1)
|
||||||
|
run_colourful_console
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
run_generate_sshd_commands
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
run_setup_tmux
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid choice."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
42
report-host-status
Normal file
42
report-host-status
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# [TESTING]
|
||||||
|
#
|
||||||
|
# Purpose:
|
||||||
|
# This script collects status of the host system and sends it to a remote endpoint.
|
||||||
|
#
|
||||||
|
# Specifications:
|
||||||
|
# - Take first argument for status to collect and send.
|
||||||
|
# - disk: disk usage, using df
|
||||||
|
# - memory: memory usage, using free
|
||||||
|
# - The base URL to the API endpoint is set in a file named ".api-endpoint" located in the script's directory.
|
||||||
|
# - If the file does not exist, the script returns an error and terminates, do not exit to prevent breaking SSH session.
|
||||||
|
# - The path to the API is /host-report
|
||||||
|
# - The script sends a POST request with the collected data in form-data format to the specified endpoint.
|
||||||
|
# - The form-data contains these fields:
|
||||||
|
# - machine: the current hostname
|
||||||
|
# - type: the type of status being reported (disk or memory)
|
||||||
|
# - data: the collected status data
|
||||||
|
|
||||||
|
if [ ! -f ".api-endpoint" ]; then
|
||||||
|
echo "Error: .api-endpoint file not found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
API_ENDPOINT=$(cat .api-endpoint)
|
||||||
|
|
||||||
|
if [ "$#" -ne 1 ] || { [ "$1" != "disk" ] && [ "$1" != "memory" ]; }; then
|
||||||
|
echo "Usage: $0 disk|memory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
STATUS_TYPE=$1
|
||||||
|
MACHINE=$(hostname)
|
||||||
|
|
||||||
|
if [ "$STATUS_TYPE" == "disk" ]; then
|
||||||
|
DATA=$(df -h)
|
||||||
|
elif [ "$STATUS_TYPE" == "memory" ]; then
|
||||||
|
DATA=$(free -h)
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -X POST "$API_ENDPOINT/host-report" -d "machine=$MACHINE&type=$STATUS_TYPE&data=$DATA"
|
||||||
33
templates/_tmux.conf
Normal file
33
templates/_tmux.conf
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# List of plugins
|
||||||
|
set -g @plugin 'tmux-plugins/tpm'
|
||||||
|
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||||
|
set -g @plugin 'tmux-plugins/tmux-resurrect'
|
||||||
|
|
||||||
|
set -g display-panes-time 3000
|
||||||
|
set -g repeat-time 720
|
||||||
|
|
||||||
|
# Customization
|
||||||
|
|
||||||
|
# Split window with | & -
|
||||||
|
bind | split-window -h
|
||||||
|
bind - split-window -v
|
||||||
|
unbind '"'
|
||||||
|
unbind %
|
||||||
|
|
||||||
|
# Switch panes using Alt-arrow without prefix
|
||||||
|
bind -n M-Left select-pane -L
|
||||||
|
bind -n M-Right select-pane -R
|
||||||
|
bind -n M-Up select-pane -U
|
||||||
|
bind -n M-Down select-pane -D
|
||||||
|
|
||||||
|
# Enable mouse control (clickable windows, panes, resizable panes)
|
||||||
|
# For -V 2.0
|
||||||
|
#set -g mouse-select-window on
|
||||||
|
#set -g mouse-select-pane on
|
||||||
|
#set -g mouse-resize-pane on
|
||||||
|
# For -V 2.1
|
||||||
|
set -g mouse on
|
||||||
|
|
||||||
|
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
|
||||||
|
run '~/.tmux/plugins/tpm/tpm'
|
||||||
|
|
||||||
Reference in New Issue
Block a user