Skip to content

Commit e653f94

Browse files
committed
fix: user-space permission fixes for installation with non-root users
1 parent 02ffcab commit e653f94

File tree

3 files changed

+31
-36
lines changed

3 files changed

+31
-36
lines changed

alpine/alpine-node-dev.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ set -e
88
## Script to install an opinionated dev environment, check out: gh:namesmt/linux-stuff
99

1010
# Install basic packages
11-
apk update
12-
apk add --no-cache \
11+
sudo apk update
12+
sudo apk add --no-cache \
1313
gcompat libstdc++ \
1414
zip unzip jq sudo git less zsh curl wget
1515

@@ -28,9 +28,8 @@ sh -c "$(wget -qO- https://github.com/deluan/zsh-in-docker/releases/latest/downl
2828
-p https://github.com/zsh-users/zsh-syntax-highlighting
2929

3030
# set zsh as default shell
31-
sed -i 's/\/root:\/bin\/ash/\/root:\/bin\/zsh/g' /etc/passwd
32-
sed -i 's/\/root:\/bin\/sh/\/root:\/bin\/zsh/g' /etc/passwd
33-
zsh
31+
sudo sed -i 's/\/root:\/bin\/ash/\/root:\/bin\/zsh/g' /etc/passwd
32+
sudo sed -i 's/\/root:\/bin\/sh/\/root:\/bin\/zsh/g' /etc/passwd
3433
export SHELL=/bin/zsh
3534

3635
# Install fnm (patched for alpine zsh) and install lts node using fnm
@@ -39,9 +38,10 @@ source ~/.zshrc
3938
fnm install --lts
4039

4140
# Setup the environment path for pnpm
42-
touch /etc/profile.d/pnpmPath.sh && \
43-
echo 'export PNPM_HOME=/root/.local/share/pnpm' >> /etc/profile.d/pnpmPath.sh && \
44-
echo 'export PATH=$PNPM_HOME:$PATH' >> /etc/profile.d/pnpmPath.sh && \
41+
mkdir ~/.pnpm-global
42+
sudo touch /etc/profile.d/pnpmPath.sh && \
43+
echo 'export PNPM_HOME=$HOME/.pnpm-global' | sudo tee -a /etc/profile.d/pnpmPath.sh && \
44+
echo 'export PATH=$PNPM_HOME:$PATH' | sudo tee -a /etc/profile.d/pnpmPath.sh && \
4545
source /etc/profile.d/pnpmPath.sh
4646

4747
# Install pnpm and ni
@@ -50,11 +50,11 @@ corepack enable
5050
corepack prepare pnpm --activate
5151
pnpm i -g @antfu/ni && \
5252
touch ~/.nirc && \
53-
echo 'defaultAgent=pnpm' >> ~/.nirc && \
54-
echo 'globalAgent=pnpm' >> ~/.nirc
53+
echo 'defaultAgent=pnpm' | tee -a ~/.nirc && \
54+
echo 'globalAgent=pnpm' | tee -a ~/.nirc
5555

5656
# Adding a simple command to change git remote connection from/to ssh/https
57-
touch /etc/profile.d/gitRemoteChanger.sh && \
58-
echo alias git-ssh=\'git remote set-url origin \"\$\(git remote get-url origin \| sed -E \'\\\'\'s,\^https://\(\[\^/\]\*\)/\(.\*\)\$,git@\\1:\\2,\'\\\'\'\)\"\' >> /etc/profile.d/gitRemoteChanger.sh && \
59-
echo alias git-https=\'git remote set-url origin \"\$\(git remote get-url origin \| sed -E \'\\\'\'s,\^git@\(\[\^:\]\*\):/\*\(.\*\)\$,https://\\1/\\2,\'\\\'\'\)\"\' >> /etc/profile.d/gitRemoteChanger.sh && \
57+
sudo touch /etc/profile.d/gitRemoteChanger.sh && \
58+
echo alias git-ssh=\'git remote set-url origin \"\$\(git remote get-url origin \| sed -E \'\\\'\'s,\^https://\(\[\^/\]\*\)/\(.\*\)\$,git@\\1:\\2,\'\\\'\'\)\"\' | sudo tee -a /etc/profile.d/gitRemoteChanger.sh && \
59+
echo alias git-https=\'git remote set-url origin \"\$\(git remote get-url origin \| sed -E \'\\\'\'s,\^git@\(\[\^:\]\*\):/\*\(.\*\)\$,https://\\1/\\2,\'\\\'\'\)\"\' | sudo tee -a /etc/profile.d/gitRemoteChanger.sh && \
6060
source /etc/profile.d/gitRemoteChanger.sh

arch/arch-node-dev.sh

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ set -e
77
## Whats this?
88
## Script to install an opinionated dev environment, check out: gh:namesmt/linux-stuff
99

10-
# Update package database, keychain, and trust database
11-
sudo pacman-key --init
12-
sudo pacman-key --populate archlinux
13-
sudo pacman -Sy archlinux-keyring --noconfirm
14-
1510
# Install basic packages
1611
sudo pacman -S --noconfirm \
1712
zip unzip jq sudo git less zsh curl wget
@@ -32,7 +27,6 @@ sh -c "$(wget -qO- https://github.com/deluan/zsh-in-docker/releases/latest/downl
3227

3328
# set zsh as default shell
3429
sudo sed -i 's/\/bin\/bash/\/bin\/zsh/g' /etc/passwd
35-
zsh
3630
export SHELL=/bin/zsh
3731

3832
# Install fnm and install lts node using fnm
@@ -41,9 +35,10 @@ source ~/.zshrc
4135
fnm install --lts
4236

4337
# Setup the environment path for pnpm
44-
touch /etc/profile.d/pnpmPath.sh && \
45-
echo 'export PNPM_HOME=/root/.local/share/pnpm' >> /etc/profile.d/pnpmPath.sh && \
46-
echo 'export PATH=$PNPM_HOME:$PATH' >> /etc/profile.d/pnpmPath.sh && \
38+
mkdir ~/.pnpm-global
39+
sudo touch /etc/profile.d/pnpmPath.sh && \
40+
echo 'export PNPM_HOME=$HOME/.pnpm-global' | sudo tee -a /etc/profile.d/pnpmPath.sh && \
41+
echo 'export PATH=$PNPM_HOME:$PATH' | sudo tee -a /etc/profile.d/pnpmPath.sh && \
4742
source /etc/profile.d/pnpmPath.sh
4843

4944
# Install pnpm and ni
@@ -52,11 +47,11 @@ corepack enable
5247
corepack prepare pnpm --activate
5348
pnpm i -g @antfu/ni && \
5449
touch ~/.nirc && \
55-
echo 'defaultAgent=pnpm' >> ~/.nirc && \
56-
echo 'globalAgent=pnpm' >> ~/.nirc
50+
echo 'defaultAgent=pnpm' | tee -a ~/.nirc && \
51+
echo 'globalAgent=pnpm' | tee -a ~/.nirc
5752

5853
# Adding a simple command to change git remote connection from/to ssh/https
59-
touch /etc/profile.d/gitRemoteChanger.sh && \
60-
echo alias git-ssh=\'git remote set-url origin \"\$\(git remote get-url origin \| sed -E \'\\\'\'s,\^https://\(\[\^/\]\*\)/\(.\*\)\$,git@\\1:\\2,\'\\\'\'\)\"\' >> /etc/profile.d/gitRemoteChanger.sh && \
61-
echo alias git-https=\'git remote set-url origin \"\$\(git remote get-url origin \| sed -E \'\\\'\'s,\^git@\(\[\^:\]\*\):/\*\(.\*\)\$,https://\\1/\\2,\'\\\'\'\)\"\' >> /etc/profile.d/gitRemoteChanger.sh && \
54+
sudo touch /etc/profile.d/gitRemoteChanger.sh && \
55+
echo alias git-ssh=\'git remote set-url origin \"\$\(git remote get-url origin \| sed -E \'\\\'\'s,\^https://\(\[\^/\]\*\)/\(.\*\)\$,git@\\1:\\2,\'\\\'\'\)\"\' | sudo tee -a /etc/profile.d/gitRemoteChanger.sh && \
56+
echo alias git-https=\'git remote set-url origin \"\$\(git remote get-url origin \| sed -E \'\\\'\'s,\^git@\(\[\^:\]\*\):/\*\(.\*\)\$,https://\\1/\\2,\'\\\'\'\)\"\' | sudo tee -a /etc/profile.d/gitRemoteChanger.sh && \
6257
source /etc/profile.d/gitRemoteChanger.sh

ubuntu/ubuntu-node-dev.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ sh -c "$(wget -qO- https://github.com/deluan/zsh-in-docker/releases/latest/downl
2828

2929
# set zsh as default shell
3030
sudo sed -i 's/\/bin\/bash/\/bin\/zsh/g' /etc/passwd
31-
zsh
3231
export SHELL=/bin/zsh
3332

3433
# Install fnm and install lts node using fnm
@@ -37,9 +36,10 @@ source ~/.zshrc
3736
fnm install --lts
3837

3938
# Setup the environment path for pnpm
40-
touch /etc/profile.d/pnpmPath.sh && \
41-
echo 'export PNPM_HOME=/root/.local/share/pnpm' >> /etc/profile.d/pnpmPath.sh && \
42-
echo 'export PATH=$PNPM_HOME:$PATH' >> /etc/profile.d/pnpmPath.sh && \
39+
mkdir ~/.pnpm-global
40+
sudo touch /etc/profile.d/pnpmPath.sh && \
41+
echo 'export PNPM_HOME=$HOME/.pnpm-global' | sudo tee -a /etc/profile.d/pnpmPath.sh && \
42+
echo 'export PATH=$PNPM_HOME:$PATH' | sudo tee -a /etc/profile.d/pnpmPath.sh && \
4343
source /etc/profile.d/pnpmPath.sh
4444

4545
# Install pnpm and ni
@@ -48,11 +48,11 @@ corepack enable
4848
corepack prepare pnpm --activate
4949
pnpm i -g @antfu/ni && \
5050
touch ~/.nirc && \
51-
echo 'defaultAgent=pnpm' >> ~/.nirc && \
52-
echo 'globalAgent=pnpm' >> ~/.nirc
51+
echo 'defaultAgent=pnpm' | tee -a ~/.nirc && \
52+
echo 'globalAgent=pnpm' | tee -a ~/.nirc
5353

5454
# Adding a simple command to change git remote connection from/to ssh/https
55-
touch /etc/profile.d/gitRemoteChanger.sh && \
56-
echo alias git-ssh=\'git remote set-url origin \"\$\(git remote get-url origin \| sed -E \'\\\'\'s,\^https://\(\[\^/\]\*\)/\(.\*\)\$,git@\\1:\\2,\'\\\'\'\)\"\' >> /etc/profile.d/gitRemoteChanger.sh && \
57-
echo alias git-https=\'git remote set-url origin \"\$\(git remote get-url origin \| sed -E \'\\\'\'s,\^git@\(\[\^:\]\*\):/\*\(.\*\)\$,https://\\1/\\2,\'\\\'\'\)\"\' >> /etc/profile.d/gitRemoteChanger.sh && \
55+
sudo touch /etc/profile.d/gitRemoteChanger.sh && \
56+
echo alias git-ssh=\'git remote set-url origin \"\$\(git remote get-url origin \| sed -E \'\\\'\'s,\^https://\(\[\^/\]\*\)/\(.\*\)\$,git@\\1:\\2,\'\\\'\'\)\"\' | sudo tee -a /etc/profile.d/gitRemoteChanger.sh && \
57+
echo alias git-https=\'git remote set-url origin \"\$\(git remote get-url origin \| sed -E \'\\\'\'s,\^git@\(\[\^:\]\*\):/\*\(.\*\)\$,https://\\1/\\2,\'\\\'\'\)\"\' | sudo tee -a /etc/profile.d/gitRemoteChanger.sh && \
5858
source /etc/profile.d/gitRemoteChanger.sh

0 commit comments

Comments
 (0)