Skip to content

Commit da4585d

Browse files
committed
Merge branch 'main' of github.com:1995parham/dotfiles
2 parents 0bad8e4 + 184566b commit da4585d

12 files changed

Lines changed: 291 additions & 28 deletions

File tree

incus/ansible.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#cloud-config
2+
3+
# Bootstrap an Ubuntu VM with the parham_alvani.dotfiles ansible collection
4+
# applied. The collection installs zsh/vim/tmux/git config and other tooling;
5+
# anything else (vault, etc.) is layered on later via additional playbooks.
6+
7+
package_update: true
8+
package_upgrade: true
9+
10+
packages:
11+
- ansible
12+
- git
13+
14+
users:
15+
- name: parham
16+
groups: sudo
17+
sudo: "ALL=(ALL) NOPASSWD:ALL"
18+
shell: /bin/bash
19+
lock_passwd: true
20+
21+
write_files:
22+
- path: /home/parham/playbook.yaml
23+
owner: parham:parham
24+
permissions: "0644"
25+
content: |
26+
---
27+
- name: Apply parham_alvani.dotfiles
28+
hosts: localhost
29+
connection: local
30+
gather_facts: true
31+
vars:
32+
setup_dotfiles_home: /home/parham/dotfiles
33+
setup_git_email: parham.alvani@gmail.com
34+
setup_git_name: Parham Alvani
35+
setup_github_keys_username: 1995parham
36+
ansible_user: parham
37+
tasks:
38+
- name: Apply role
39+
ansible.builtin.include_role:
40+
name: parham_alvani.dotfiles.setup
41+
42+
runcmd:
43+
- su - parham -c 'ansible-galaxy collection install git+https://github.com/1995parham-me/ansible-role.git,main'
44+
- su - parham -c 'ansible-playbook /home/parham/playbook.yaml 2>&1 | tee /home/parham/playbook.log'

scripts/colima.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ usage() {
1414

1515
root=${root:?"root must be set"}
1616

17+
# Colima needs the docker CLI; container-cli installs it (and shared tooling).
18+
export dependencies=("container-cli")
19+
1720
pre_main() {
1821
msg 'Colima provides container runtimes (Docker, Containerd, Incus) on macOS'
1922
msg 'This script will install Colima and optionally configure it'
@@ -29,9 +32,6 @@ pre_main() {
2932
main_brew() {
3033
msg "Install Colima"
3134
require_brew colima
32-
33-
msg "Install Docker CLI (required for docker runtime)"
34-
require_brew docker docker-compose docker-credential-helper docker-buildx
3535
}
3636

3737
main_pacman() {

scripts/container-cli.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
usage() {
4+
echo "engine-agnostic container CLI tools (docker CLI, compose, buildx, lazydocker, hadolint, dive, crane)"
5+
6+
# shellcheck disable=1004,2016
7+
echo '
8+
_ _ _ _
9+
___ ___ _ __ | |_ __ _(_)_ __ ___ _ __ __| (_)
10+
/ __/ _ \| |_ \| __/ _` | | |_ \ / _ \ |__|_____ / _` | |
11+
| (_| (_) | | | | || (_| | | | | | __/ | |_____| (_| | |
12+
\___\___/|_| |_|\__\__,_|_|_| |_|\___|_| \__,_|_|
13+
'
14+
}
15+
16+
root=${root:?"root must be set"}
17+
18+
main_brew() {
19+
msg 'install Docker CLI and plugins (engine-agnostic)'
20+
require_brew docker docker-compose docker-buildx docker-credential-helper docker-completion
21+
22+
msg 'install container introspection and quality tools'
23+
require_brew lazydocker hadolint dive crane
24+
}
25+
26+
main_pacman() {
27+
msg 'install cross-engine container tools'
28+
require_pacman dive crane
29+
require_aur hadolint-bin lazydocker
30+
}
31+
32+
main_apt() {
33+
require_apt curl ca-certificates
34+
35+
require_github_release "google/go-containerregistry" "crane" "go-containerregistry_Linux_x86_64" "tar.gz"
36+
require_github_release "wagoodman/dive" "dive" "dive_\${version#v}_linux_amd64" "tar.gz"
37+
require_github_release "hadolint/hadolint" "hadolint" "hadolint-Linux-x86_64"
38+
require_github_release "jesseduffield/lazydocker" "lazydocker" "lazydocker_\${version#v}_Linux_x86_64" "tar.gz"
39+
}
40+
41+
main() {
42+
if command -v docker &>/dev/null; then
43+
msg "$(docker --version 2>/dev/null || echo 'docker CLI installed')"
44+
fi
45+
if command -v hadolint &>/dev/null; then
46+
msg "$(hadolint --version)"
47+
fi
48+
if command -v crane &>/dev/null; then
49+
msg "$(crane version 2>/dev/null || echo 'crane installed')"
50+
fi
51+
}

scripts/container.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
usage() {
4+
echo "container engine selector — install CLI tools then choose engine(s) to install"
5+
6+
# shellcheck disable=1004,2016
7+
echo '
8+
_ _
9+
___ ___ _ __ | |_ __ _(_)_ __ ___ _ __
10+
/ __/ _ \| |_ \| __/ _` | | |_ \ / _ \ |__|
11+
| (_| (_) | | | | || (_| | | | | | __/ |
12+
\___\___/|_| |_|\__\__,_|_|_| |_|\___|_|
13+
'
14+
}
15+
16+
root=${root:?"root must be set"}
17+
18+
# Engines available per platform. The framework prompts per item.
19+
if [[ "${OSTYPE}" == "darwin"* ]]; then
20+
export additionals=("docker" "podman" "colima")
21+
else
22+
export additionals=("docker" "podman")
23+
fi
24+
25+
# The selector itself installs nothing; deps + additionals do the work.
26+
main_brew() { return 0; }
27+
main_apt() { return 0; }
28+
main_pacman() { return 0; }
29+
main_xbps() { return 0; }
30+
31+
main() {
32+
msg 'pick one or more engines from the prompts that follow.' 'notice'
33+
}

scripts/docker.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
usage() {
4-
echo "install docker, docker-compose, hadolint etc."
4+
echo "install the docker engine (Docker Desktop on macOS, docker-ce/docker.io on Linux)"
55

66
# shellcheck disable=1004,2016
77
echo '
@@ -90,7 +90,7 @@ main_apt() {
9090
}
9191

9292
main_xbps() {
93-
require_xbps docker docker-cli docker-compose crun
93+
require_xbps docker crun
9494

9595
configure_docker_daemon || return 1
9696
setup_docker_user
@@ -106,7 +106,6 @@ main_xbps() {
106106

107107
main_brew() {
108108
require_brew_cask docker
109-
require_brew lazydocker hadolint docker-completion dive
110109

111110
if [ -d "/Applications/Docker.app" ]; then
112111
msg "Launching Docker Desktop. You may need to grant permissions."
@@ -121,8 +120,7 @@ main_brew() {
121120
}
122121

123122
main_pacman() {
124-
require_pacman docker docker-compose dive docker-buildx crun
125-
require_aur hadolint-bin lazydocker
123+
require_pacman docker docker-compose docker-buildx crun
126124

127125
configure_docker_daemon || return 1
128126

@@ -161,10 +159,6 @@ main() {
161159
done
162160

163161
msg "$(docker version)"
164-
165-
if command -v hadolint &>/dev/null; then
166-
msg "$(hadolint --version)"
167-
fi
168162
}
169163

170164
main_parham() {

scripts/incus.sh

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env bash
2+
3+
usage() {
4+
echo "install Incus, a system container and virtual machine manager"
5+
6+
# shellcheck disable=1004
7+
echo '
8+
_
9+
(_)_ __ ___ _ _ ___
10+
| | |_ \ / __| | | / __|
11+
| | | | | (__| |_| \__ \
12+
|_|_| |_|\___|\__,_|___/
13+
'
14+
}
15+
16+
root=${root:?"root must be set"}
17+
18+
setup_incus_user() {
19+
msg "manage incus as a non-root user"
20+
sudo groupadd -f incus-admin
21+
sudo usermod -aG incus-admin "$USER"
22+
}
23+
24+
initialize_incus() {
25+
if sudo incus info >/dev/null 2>&1 &&
26+
sudo incus storage list --format csv 2>/dev/null | grep -q .; then
27+
msg 'incus already initialized' 'notice'
28+
return 0
29+
fi
30+
31+
if yes_or_no 'incus' 'initialize incus with default settings (--minimal)?'; then
32+
if ! sudo incus admin init --minimal; then
33+
msg 'failed to initialize incus' 'error'
34+
return 1
35+
fi
36+
else
37+
msg 'skipping incus init -- run "incus admin init" manually later' 'notice'
38+
fi
39+
}
40+
41+
setup_parham_profile() {
42+
local profile='parham'
43+
local user_data="$root/incus/ansible.yaml"
44+
45+
if [ ! -f "$user_data" ]; then
46+
msg "cloud-init user-data not found at $user_data" 'error'
47+
return 1
48+
fi
49+
50+
if ! sudo incus profile show "$profile" >/dev/null 2>&1; then
51+
msg "creating incus profile '$profile'"
52+
if ! sudo incus profile create "$profile" >/dev/null; then
53+
msg "failed to create incus profile '$profile'" 'error'
54+
return 1
55+
fi
56+
else
57+
msg "incus profile '$profile' already exists, updating" 'notice'
58+
fi
59+
60+
msg "loading $user_data into '$profile' profile"
61+
if ! sudo cat "$user_data" | sudo incus profile set "$profile" cloud-init.user-data -; then
62+
msg "failed to set cloud-init.user-data on '$profile'" 'error'
63+
return 1
64+
fi
65+
}
66+
67+
main_pacman() {
68+
require_pacman incus qemu-base
69+
70+
if ! sudo systemctl enable --now incus.socket incus.service; then
71+
msg 'failed to enable incus service' 'error'
72+
return 1
73+
fi
74+
75+
setup_incus_user
76+
initialize_incus || return 1
77+
setup_parham_profile
78+
}
79+
80+
main_apt() {
81+
require_apt incus qemu-system
82+
83+
if ! sudo systemctl enable --now incus.socket incus.service; then
84+
msg 'failed to enable incus service' 'error'
85+
return 1
86+
fi
87+
88+
setup_incus_user
89+
initialize_incus || return 1
90+
setup_parham_profile
91+
}
92+
93+
main_brew() {
94+
msg 'Incus does not run as a host on macOS -- installing the client only.' 'notice'
95+
require_brew incus
96+
}
97+
98+
main() {
99+
if command -v incus >/dev/null; then
100+
msg "$(incus --version)"
101+
fi
102+
103+
msg 're-login (or "newgrp incus-admin") to pick up group membership' 'notice'
104+
msg 'launch a VM with: incus launch images:ubuntu/26.04 dev --vm -p default -p parham' 'info'
105+
}

scripts/lib/whereami.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
whereami() {
1111
local ip_country_url="http://ip-api.com/json/?fields=status,query,country,isp,proxy,hosting"
1212
local fallback_ip_country_url="http://ifconfig.io/all.json"
13-
local iran_access_ip_url="https://ipnumberia.com/"
13+
local iran_access_ip_url="https://ipmyp.ir/"
1414
local cache_file="/tmp/whereami.sh"
1515
local timestamp_file="/tmp/whereami.timestamp"
1616
local ip name label

scripts/podman.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,6 @@ main_brew() {
165165
require_brew podman podman-compose
166166

167167
ensure_podman_machine
168-
169-
sudo tee /usr/local/bin/docker <<EOF
170-
#!/bin/sh
171-
[ -e /etc/containers/nodocker ] ||
172-
echo "Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg." >&2
173-
exec podman "\$@"
174-
EOF
175-
sudo chmod +x /usr/local/bin/docker
176-
177168
}
178169

179170
main() {

scripts/typst.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
usage() {
4+
echo -n "Typst is a new markup-based typesetting system that is designed to be as powerful as LaTeX while being much easier to learn and use."
5+
# shellcheck disable=1004
6+
echo '
7+
_ _
8+
| |_ _ _ _ __ ___| |_
9+
| __| | | | |_ \/ __| __|
10+
| |_| |_| | |_) \__ \ |_
11+
\__|\__, | .__/|___/\__|
12+
|___/|_|
13+
'
14+
}
15+
16+
main_pacman() {
17+
require_pacman typst typstyle tinymist ttf-font-awesome
18+
}
19+
20+
main_brew() {
21+
require_brew typst typstyle tinymist
22+
require_brew_cask font-fontawesome
23+
}
24+
25+
main_apt() {
26+
return 1
27+
}
28+
29+
main_xbps() {
30+
return 1
31+
}

0 commit comments

Comments
 (0)