2023-08-25 10:29:22 -06:00
|
|
|
#!/bin/bash
|
2023-08-25 12:20:22 -06:00
|
|
|
if [[ -z "${HOME_USER}" ]]; then
|
|
|
|
HOME_USER="vscode"
|
|
|
|
fi
|
|
|
|
|
2023-08-25 19:20:38 -06:00
|
|
|
addgroup nonroot
|
2023-08-25 12:20:22 -06:00
|
|
|
adduser --disabled-password --gecos "" ${HOME_USER}
|
|
|
|
echo "${HOME_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
2023-08-25 19:20:38 -06:00
|
|
|
|
2023-08-29 10:11:28 -06:00
|
|
|
#Creating extensions folder
|
|
|
|
sudo mkdir /home/${HOME_USER}/.vscode-server
|
|
|
|
sudo chmod -R a+rwX /home/${HOME_USER}/.vscode-server
|
|
|
|
code --extensions-dir /home/${HOME_USER}/.vscode-server
|
|
|
|
|
2023-08-29 06:56:31 -06:00
|
|
|
# Check if the data.json file exists
|
|
|
|
if [ -f "/home/extensions.json" ]; then
|
|
|
|
# Read the JSON file into a variable
|
|
|
|
jsonExtensions=$(cat /home/extensions.json)
|
|
|
|
|
|
|
|
# Use jq to extract the array elements
|
|
|
|
extensions=$(echo $jsonExtensions | jq -r '.[]')
|
|
|
|
|
|
|
|
# Loop through the extensions and process each element
|
|
|
|
for extension in $extensions; do
|
|
|
|
echo "Installing extension: $extension"
|
2023-08-29 10:11:28 -06:00
|
|
|
sudo su - ${HOME_USER} -c "code --install-extension $extension --extensions-dir "
|
2023-08-29 06:56:31 -06:00
|
|
|
done
|
2023-08-29 09:15:48 -06:00
|
|
|
#sudo mkdir /home/${HOME_USER}/.vscode-server
|
|
|
|
#sudo mkdir /home/${HOME_USER}/.vscode-server-insiders
|
|
|
|
#sudo cp -R /home/${HOME_USER}/.vscode/* /home/${HOME_USER}/.vscode-server
|
|
|
|
#sudo cp -R /home/${HOME_USER}/.vscode/* /home/${HOME_USER}.vscode-server-insiders
|
|
|
|
#sudo chmod -R a+rwX /home/${HOME_USER}/.vscode
|
|
|
|
#sudo chmod -R a+rwX /home/${HOME_USER}/.vscode-server
|
|
|
|
#sudo chmod -R a+rwX /home/${HOME_USER}/.vscode-server-insiders
|
2023-08-29 06:56:31 -06:00
|
|
|
else
|
|
|
|
echo "File extensions.json not found"
|
|
|
|
fi
|
|
|
|
|
2023-08-25 12:20:22 -06:00
|
|
|
if [[ -z "${VSCODE_TUNNEL_NAME}" ]]; then
|
2023-08-26 22:53:21 -06:00
|
|
|
sudo su - ${HOME_USER} -c "code tunnel --accept-server-license-terms"
|
2023-08-25 12:20:22 -06:00
|
|
|
else
|
2023-08-26 22:53:21 -06:00
|
|
|
sudo su - ${HOME_USER} -c "code tunnel --accept-server-license-terms --name ${VSCODE_TUNNEL_NAME}"
|
2023-08-25 12:20:22 -06:00
|
|
|
fi
|