-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0dd51b9
commit 4fe3560
Showing
51 changed files
with
1,551 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
VERSION="0.5.1" | ||
BASE_URL="https://storage.slv.dev/slv" | ||
|
||
detect_platform() { | ||
uname_out="$(uname -s)" | ||
case "${uname_out}" in | ||
Linux*) platform="x86_64-unknown-linux-gnu"; osfamily="linux";; | ||
Darwin*) platform="x86_64-apple-darwin"; osfamily="darwin";; | ||
CYGWIN*|MINGW*|MSYS*|Windows*) platform="x86_64-pc-windows-msvc"; osfamily="windows";; | ||
*) echo "Unsupported platform: ${uname_out}" && exit 1;; | ||
esac | ||
} | ||
|
||
install_slv() { | ||
echo "Detecting platform..." | ||
detect_platform | ||
echo "Platform detected: $platform" | ||
|
||
DOWNLOAD_URL="${BASE_URL}/${VERSION}/${platform}-exe.tar.gz?cachebuster=$(date +%s)" | ||
TEMPLATE_URL="${BASE_URL}/template/${VERSION}/template.tar.gz?cachebuster=$(date +%s)" | ||
INSTALL_DIR="/usr/local/bin" | ||
TEMPLATE_DIR="$HOME/.slv/template" | ||
TEMP_DIR=$(mktemp -d) | ||
mkdir -p "$HOME/.slv" | ||
mkdir -p "$HOME/.slv/keys" | ||
|
||
if [ "$platform" = "x86_64-pc-windows-msvc" ]; then | ||
INSTALL_DIR="$HOME/.local/bin" | ||
mkdir -p "$INSTALL_DIR" | ||
fi | ||
|
||
echo "Temporary directory: $TEMP_DIR" | ||
|
||
echo "Downloading slv from $DOWNLOAD_URL..." | ||
curl -fsSL "$DOWNLOAD_URL" -o "$TEMP_DIR/slv.tar.gz" | ||
|
||
echo "Downloading templates from $TEMPLATE_URL..." | ||
curl -fsSL "$TEMPLATE_URL" -o "$HOME/.slv/template.tar.gz" | ||
|
||
echo "Extracting slv..." | ||
tar -xzvf "$TEMP_DIR/slv.tar.gz" -C "$TEMP_DIR" --strip-components=1 | ||
|
||
echo "Extracting templates..." | ||
tar -xzvf "$HOME/.slv/template.tar.gz" -C "$HOME/.slv" --strip-components=1 | ||
mkdir -p "$HOME/.slv/template" | ||
echo "Copying templates to $HOME/.slv/template" | ||
|
||
SLV_FILE="$TEMP_DIR/slv-x86_64-apple-darwin-exe" | ||
TEMPLATE_DL_DIR="$HOME/.slv/" | ||
|
||
if [ ! -f "$SLV_FILE" ]; then | ||
echo "Error: Extracted file not found." | ||
exit 1 | ||
fi | ||
|
||
echo "Installing slv..." | ||
if [ ! -d "$INSTALL_DIR" ]; then | ||
echo "$INSTALL_DIR does not exist. Creating it..." | ||
sudo mkdir -p "$INSTALL_DIR" | ||
fi | ||
|
||
if [ "$platform" = "x86_64-apple-darwin" ]; then | ||
SLV_FILE="$TEMP_DIR/slv-x86_64-apple-darwin-exe" | ||
elif [ "$platform" = "x86_64-unknown-linux-gnu" ]; then | ||
SLV_FILE="$TEMP_DIR/slv-x86_64-unknown-linux-gnu-exe" | ||
elif [ "$platform" = "x86_64-pc-windows-msvc" ]; then | ||
SLV_FILE="$TEMP_DIR/slv-x86_64-pc-windows-msvc.exe" | ||
fi | ||
|
||
echo "Cleaning up..." | ||
rm -rf "$TEMP_DIR" | ||
rm -rf "$TEMP_DIR2" | ||
rm -rf "$HOME/.slv/template.tar.gz" | ||
|
||
echo "slv has been installed successfully!" | ||
echo "Ensure $INSTALL_DIR is in your PATH." | ||
if [ "$platform" = "x86_64-pc-windows-msvc" ]; then | ||
echo "Windows users, add $INSTALL_DIR to your PATH manually." | ||
fi | ||
mkdir -p ~/.slv/keys | ||
slv -P | ||
} | ||
|
||
install_slv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
- name: Create solv user with specific password and configure SSH access | ||
hosts: all | ||
become: yes | ||
vars: | ||
home_paths_authorized_keys: /home/solv/.ssh/authorized_keys | ||
ansible_remote_tmp: /tmp/ansible_tmp | ||
local_public_key_path: "{{ lookup('env', 'HOME') + '/.ssh/id_rsa.pub' }}" | ||
vars_files: | ||
- ~/.slv/config.pwd.yml | ||
tasks: | ||
- name: Ensure solv user exists | ||
user: | ||
name: solv | ||
password: "{{ encrypted_password }}" | ||
state: present | ||
shell: /bin/bash | ||
|
||
- name: Ensure .ssh directory exists for solv user | ||
file: | ||
path: /home/solv/.ssh | ||
state: directory | ||
owner: solv | ||
group: solv | ||
mode: "0700" | ||
|
||
- name: Add local public key to authorized_keys | ||
lineinfile: | ||
path: "{{ home_paths_authorized_keys }}" | ||
line: "{{ lookup('file', local_public_key_path) }}" | ||
create: yes | ||
owner: solv | ||
group: solv | ||
mode: "0600" | ||
|
||
- name: Generate SSH key for solv user if not exists | ||
shell: su - solv -c "ssh-keygen -t rsa -b 4096 -N '' -f /home/solv/.ssh/id_rsa" | ||
args: | ||
creates: /home/solv/.ssh/id_rsa | ||
|
||
- name: Ensure correct permissions for .ssh directory | ||
file: | ||
path: /home/solv/.ssh | ||
state: directory | ||
owner: solv | ||
group: solv | ||
mode: "0700" | ||
|
||
- name: Ensure correct permissions for authorized_keys | ||
file: | ||
path: "{{ home_paths_authorized_keys }}" | ||
state: file | ||
owner: solv | ||
group: solv | ||
mode: "0600" | ||
|
||
- name: Add solv user to sudoers group | ||
user: | ||
name: solv | ||
groups: sudo | ||
append: yes | ||
|
||
- name: Configure sudoers file for solv user (no password required) | ||
lineinfile: | ||
path: /etc/sudoers | ||
state: present | ||
regexp: '^solv ALL=\(ALL\) NOPASSWD:ALL' | ||
line: "solv ALL=(ALL) NOPASSWD:ALL" | ||
validate: "visudo -cf %s" | ||
|
||
- name: Ensure PubkeyAuthentication is enabled | ||
lineinfile: | ||
path: /etc/ssh/sshd_config | ||
regexp: '^#?PubkeyAuthentication\s+.*' | ||
line: "PubkeyAuthentication yes" | ||
notify: | ||
- restart ssh | ||
|
||
- name: Ensure PasswordAuthentication is disabled | ||
lineinfile: | ||
path: /etc/ssh/sshd_config | ||
regexp: '^#?PasswordAuthentication\s+.*' | ||
line: "PasswordAuthentication no" | ||
notify: | ||
- restart ssh | ||
|
||
- name: Ensure ChallengeResponseAuthentication is disabled | ||
lineinfile: | ||
path: /etc/ssh/sshd_config | ||
regexp: '^#?ChallengeResponseAuthentication\s+.*' | ||
line: "ChallengeResponseAuthentication no" | ||
notify: | ||
- restart ssh | ||
|
||
handlers: | ||
- name: restart ssh | ||
service: | ||
name: ssh | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
find_unmounted_nvme_disks() { | ||
lsblk -nr -o NAME,TYPE,SIZE,MOUNTPOINT | awk ' | ||
$2 == "disk" && | ||
$1 ~ /^nvme/ && | ||
(($3 ~ /G$/ && substr($3, 1, length($3)-1) + 0 >= 800) || | ||
($3 ~ /T$/ && substr($3, 1, length($3)-1) + 0 >= 0.8)) && | ||
($4 == "" || $4 ~ /^[[:space:]]*$/) && | ||
system("lsblk -nr -o TYPE /dev/" $1 " | grep -q part") != 0 {print $1}' | ||
} | ||
|
||
find_unmounted_nvme_disks |
Oops, something went wrong.