Update arch_install.sh
This commit is contained in:
parent
e935a5fed1
commit
f17498547b
|
|
@ -9,6 +9,7 @@
|
|||
# - installs and enables OpenSSH
|
||||
# - installs and safely configures UFW
|
||||
# - creates an admin UNIX account
|
||||
# - installs AUR dependencies for RStudio Server
|
||||
# - installs R and RStudio Server
|
||||
# - installs JupyterHub into /opt/jupyterhub
|
||||
# - configures JupyterHub as a systemd service
|
||||
|
|
@ -100,12 +101,12 @@ install_base_packages() {
|
|||
which \
|
||||
iproute2 \
|
||||
r \
|
||||
gcc-fortran
|
||||
gcc-fortran \
|
||||
openssl
|
||||
}
|
||||
|
||||
enable_ssh() {
|
||||
log "Enabling SSH"
|
||||
|
||||
systemctl enable --now sshd
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +118,7 @@ configure_firewall() {
|
|||
|
||||
log "Configuring UFW firewall safely"
|
||||
|
||||
# Always allow SSH first so remote access is not lost
|
||||
# Allow SSH first so remote access is not lost
|
||||
ufw allow "${SSH_PORT}"/tcp
|
||||
ufw allow 80/tcp
|
||||
ufw allow 443/tcp
|
||||
|
|
@ -143,22 +144,31 @@ create_admin_user() {
|
|||
fi
|
||||
}
|
||||
|
||||
install_rstudio_server() {
|
||||
log "Installing RStudio Server from AUR (without paru)"
|
||||
install_aur_package() {
|
||||
local pkg_name="$1"
|
||||
local build_dir="${REAL_HOME}/${pkg_name}-build"
|
||||
|
||||
local build_dir="${REAL_HOME}/rstudio-server-bin-build"
|
||||
log "Installing AUR package: ${pkg_name}"
|
||||
|
||||
rm -rf "${build_dir}"
|
||||
|
||||
sudo -u "${REAL_USER}" bash -lc "
|
||||
set -Eeuo pipefail
|
||||
cd '${REAL_HOME}'
|
||||
git clone https://aur.archlinux.org/rstudio-server-bin.git '${build_dir}'
|
||||
git clone 'https://aur.archlinux.org/${pkg_name}.git' '${build_dir}'
|
||||
cd '${build_dir}'
|
||||
makepkg -si --noconfirm
|
||||
makepkg -si --noconfirm --needed
|
||||
"
|
||||
|
||||
rm -rf "${build_dir}"
|
||||
}
|
||||
|
||||
install_rstudio_server() {
|
||||
log "Installing RStudio Server from AUR"
|
||||
|
||||
# rstudio-server-bin depends on openssl-1.1, which must be installed first
|
||||
install_aur_package "openssl-1.1"
|
||||
install_aur_package "rstudio-server-bin"
|
||||
|
||||
mkdir -p /etc/rstudio
|
||||
|
||||
|
|
@ -169,9 +179,7 @@ install_rstudio_server() {
|
|||
fi
|
||||
|
||||
# Remove broken/undesired server-user entries if present
|
||||
if grep -q '^server-user=' /etc/rstudio/rserver.conf 2>/dev/null; then
|
||||
sed -i '/^server-user=/d' /etc/rstudio/rserver.conf
|
||||
fi
|
||||
sed -i '/^server-user=/d' /etc/rstudio/rserver.conf 2>/dev/null || true
|
||||
|
||||
mkdir -p /var/lib/rstudio-server
|
||||
chown -R root:root /var/lib/rstudio-server
|
||||
|
|
@ -230,13 +238,18 @@ c.JupyterHub.db_url = 'sqlite:///${JUPYTERHUB_CONFIG_DIR}/jupyterhub.sqlite'
|
|||
c.ConfigurableHTTPProxy.command = 'configurable-http-proxy'
|
||||
EOF
|
||||
|
||||
if [[ ! -f "${JUPYTERHUB_CONFIG_DIR}/jupyterhub_cookie_secret" ]]; then
|
||||
python - <<'PY'
|
||||
# JupyterHub expects a valid text/hex secret here, not raw binary
|
||||
python - <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
with open('/etc/jupyterhub/jupyterhub_cookie_secret', 'w', encoding='utf-8') as f:
|
||||
f.write(secrets.token_hex(32) + '\n')
|
||||
|
||||
path = '/etc/jupyterhub/jupyterhub_cookie_secret'
|
||||
os.makedirs('/etc/jupyterhub', exist_ok=True)
|
||||
|
||||
if not os.path.exists(path) or os.path.getsize(path) == 0:
|
||||
with open(path, 'w', encoding='utf-8') as f:
|
||||
f.write(secrets.token_hex(32) + '\n')
|
||||
PY
|
||||
fi
|
||||
|
||||
chmod 600 "${JUPYTERHUB_CONFIG_DIR}/jupyterhub_cookie_secret"
|
||||
chown root:root "${JUPYTERHUB_CONFIG_DIR}/jupyterhub_cookie_secret"
|
||||
|
|
|
|||
Loading…
Reference in New Issue