Skip to content

Commit

Permalink
Merge pull request #345 from WhitewaterFoundry/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
crramirez committed Jul 14, 2021
2 parents 4db15e1 + 072c1fa commit dca38b3
Show file tree
Hide file tree
Showing 21 changed files with 200 additions and 78 deletions.
5 changes: 4 additions & 1 deletion completions/pengwin-setup
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ function _pengwin_setup() { # By convention, the function name
mapfile -t COMPREPLY < <(compgen -W 'PYENV PYTHONPIP POETRY' -- "${cur}")
;;
SERVICES)
mapfile -t COMPREPLY < <(compgen -W 'RCLOCAL SSH' -- "${cur}")
mapfile -t COMPREPLY < <(compgen -W 'RCLOCAL SSH LAMP' -- "${cur}")
;;
LAMP)
mapfile -t COMPREPLY < <(compgen -W 'BUILTIN 10.3 10.4 10.5 10.6' -- "${cur}")
;;
SETTINGS)
mapfile -t COMPREPLY < <(compgen -W 'EXPLORER COLORTOOL LANGUAGE SHELLS' -- "${cur}")
Expand Down
2 changes: 2 additions & 0 deletions pengwin-setup
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ function check_upgrades() {
else
# Force iproute2 5.8
if [[ $( dpkg-query -s "iproute2" 2>/dev/null | grep -c "Version: 5\.8.*" ) == 0 ]]; then
sudo apt-mark unhold iproute2
sudo apt-get install -q -y --allow-downgrades iproute2=5.8.0-1
sudo apt-mark hold iproute2
fi

fi
Expand Down
10 changes: 5 additions & 5 deletions pengwin-setup.d/cloudcli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ function install_doctl() {
function install_kubectl() {

echo "Installing Helm"
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash

wget https://raw.githubusercontent.com/helm/helm/master/scripts/completions.bash
sudo cp completions.bash /etc/bash_completion.d/helm_completions.bash
helm completion bash | sudo tee /etc/bash_completion.d/helm
helm completion fish >~/.config/fish/completions/helm.fish

echo "Installing kubectl"
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
Expand Down Expand Up @@ -223,7 +223,7 @@ function install_kubernetes() {
local kube_ctl="${wHome}/.kube/config"

while [[ ! -f ${kube_ctl} ]]; do
if ! (whiptail --title "KUBERNETES" --yesno "Please enable Kubernetes in Docker Desktop. Would you like to try again?" 9 75); then
if ! (confirm --title "KUBERNETES" --yesno "Please enable Kubernetes in Docker Desktop. Would you like to try again?" 9 75); then
return

fi
Expand Down Expand Up @@ -273,7 +273,7 @@ function install_openstack() {
function main() {
# shellcheck disable=SC2155
local choice=$(
whiptail --title "Cloud Management Menu" --checklist --separate-output "CLI tools for cloud management\n[SPACE to select, ENTER to confirm]:" 16 60 7 \
menu --title "Cloud Management Menu" --checklist --separate-output "CLI tools for cloud management\n[SPACE to select, ENTER to confirm]:" 16 60 7 \
"AWS" "AWS CLI" off \
"AZURE" "Azure CLI" off \
"DO" "Digital Ocean CLI" off \
Expand Down
2 changes: 1 addition & 1 deletion pengwin-setup.d/guilib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (confirm --title "GUI Libraries" --yesno "Would you like to install a base se

echo "Configuring dbus if you already had it installed. If not, you might see some errors, and that is okay."
if [[ ${WIN_CUR_VER} -gt 17063 ]]; then
sudo rm /etc/dbus-1/session.conf
sudo rm -f /etc/dbus-1/session.conf
sudo sed -i 's$<listen>.*</listen>$<listen>unix:tmpdir=/tmp</listen>$' /usr/share/dbus-1/session.conf
sudo sed -i 's$<auth>ANONYMOUS</auth>$<auth>EXTERNAL</auth>$' /usr/share/dbus-1/session.conf
sudo sed -i 's$<allow_anonymous/></busconfig>$</busconfig>$' /usr/share/dbus-1/session.conf
Expand Down
24 changes: 18 additions & 6 deletions pengwin-setup.d/hidpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,33 @@ if (confirm --title "HiDPI" --yesno "Would you like to configure Qt and GTK for
scale_factor=$(wslsys -S -s)

sudo tee "/etc/profile.d/hidpi.sh" <<EOF
#!/bin/bash
export QT_SCALE_FACTOR=${scale_factor}
export GDK_SCALE=\$(echo "(\${QT_SCALE_FACTOR} + 0.49) / 1" | bc) #Round
export GDK_DPI_SCALE=\$(echo "\${QT_SCALE_FACTOR} / \${GDK_SCALE}" | bc -l)
#!/bin/sh
if [ -z "\${XRANDRDPI}" ] || [ "\${XRANDRDPI}" -eq 96 ]; then
scale_factor=${scale_factor}
export QT_SCALE_FACTOR=\${scale_factor}
else
scale_factor=\$(echo "\${XRANDRDPI} / 96" | bc -l)
fi
# shellcheck disable=SC2155
export GDK_SCALE=\$(echo "(\${scale_factor} + 0.49) / 1" | bc) #Round
# shellcheck disable=SC2155
export GDK_DPI_SCALE=\$(echo "\${scale_factor} / \${GDK_SCALE}" | bc -l)
if [ "\$(echo "\${QT_SCALE_FACTOR} >= 2" | bc -l)" -eq 1 ]; then
if [ "\$(echo "\${scale_factor} >= 2" | bc -l)" -eq 1 ]; then
export XCURSOR_SIZE=64
elif [ "\$(echo "\${QT_SCALE_FACTOR} >= 1.5" | bc -l)" -eq 1 ]; then
elif [ "\$(echo "\${scale_factor} >= 1.5" | bc -l)" -eq 1 ]; then
export XCURSOR_SIZE=32
else
export XCURSOR_SIZE=16
fi
unset scale_factor
EOF

# add_fish_support 'hidpi' # not working with bass

message --title "HiDPI" --msgbox "HiDPI has been adjusted to $(echo "${scale_factor} * 100 / 1" | bc)%. If you change your resolution run this option again to update your Linux applications." 10 80

Expand Down
43 changes: 33 additions & 10 deletions pengwin-setup.d/lamp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,35 @@ function install_lamp() {
local menu_choice=$(
menu --title "MariaDB" --radiolist "Choose what version of MariaDB you want to install\n[SPACE to select, ENTER to confirm]:" 14 65 5 \
"10.2" "Install MariaDB 10.2 from MariaDB" off \
"10.3" "Install MariaDB 10.3 from MariaDB" off \
"10.4" "Install MariaDB 10.4 from MariaDB" off \
"10.5" "Install MariaDB 10.5 from MariaDB" off \
"10.6" "Install MariaDB 10.6 from MariaDB" off \
"BUILTIN" "Install MariaDB from Debian Official Repo " off
# shellcheck disable=SC2188
3>&1 1>&2 2>&3
)

echo "Selected:" "${menu_choice}"
echo "Installing MariaDB Database Server"

if [[ ${menu_choice} == "CANCELLED" ]] || [[ ${menu_choice} == "BUILTIN" ]]; then
if [[ ${menu_choice} == "CANCELLED" ]]; then
return 1
fi

# shellcheck disable=SC2155
local selected_version=$(echo "${menu_choice##* }" | grep -E "10\.[1-6]?")
if [[ ${menu_choice} == *"BUILTIN"* ]]; then

if [[ -n ${NON_INTERACTIVE} ]]; then
export DEBIAN_FRONTEND=noninteractive
fi

install_packages mariadb-server mariadb-client
apt policy mariadb-server
else

elif [[ -n ${selected_version} ]]; then
if curl -sSO https://downloads.mariadb.com/MariaDB/mariadb-keyring-2019.gpg; then
if curl -sS https://downloads.mariadb.com/MariaDB/mariadb-keyring-2019.gpg.sha256 | sha256sum -c --quiet; then
echo 'Running apt-get update...'
Expand All @@ -36,24 +49,32 @@ function install_lamp() {
echo 'Done adding trusted package signing keys'
else
echo 'Failed to add trusted package signing keys'
exit 1
return 1
fi
else
echo 'Failed to verify trusted package signing keys keyring file'
exit 1
return 1
fi
else
echo 'Failed to download trusted package signing keys keyring file'
fi
sudo apt-get -y -q install software-properties-common
sudo add-apt-repository "deb http://downloads.mariadb.com/MariaDB/mariadb-${menu_choice}/repo/debian buster main"
sudo apt-get -y -q install software-properties-common libdbi-perl
sudo add-apt-repository "deb http://downloads.mariadb.com/MariaDB/mariadb-${selected_version}/repo/debian buster main"
sudo apt-get -q update
install_packages -t buster mariadb-server mariadb-client

if [[ -n ${NON_INTERACTIVE} ]]; then
export DEBIAN_FRONTEND=noninteractive
sudo debconf-set-selections <<< "mariadb-server-${selected_version} mysql-server/root_password password PASS"
sudo debconf-set-selections <<< "mariadb-server-${selected_version} mysql-server/root_password_again password PASS"
fi

install_packages -t buster mariadb-server mariadb-client mariadb-backup
apt policy mariadb-server
else
echo "${menu_choice##* } was not found"
return 1
fi

service mariadb status

echo "Installing Apache Web Server"
install_packages apache2 apache2-utils
sudo service apache2 start
Expand Down Expand Up @@ -109,6 +130,8 @@ fi
EOF

/etc/profile.d/start-lamp.sh

else
echo "Skipping SSH Server"
fi
Expand Down
12 changes: 8 additions & 4 deletions pengwin-setup.d/nodejs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ echo "Offering user n / nvm version manager choice"
menu_choice=$(
menu --title "nodejs" --radiolist "Choose Node.js install method\n[SPACE to select, ENTER to confirm]:" 12 90 4 \
"N" "Install with n version manager (fish shell compat. EXPERIMENTAL)" off \
"NVERMAN" "Install with n version manager (fish shell compat. EXPERIMENTAL)" off \
"NVM" "Install with nvm version manager (fish shell compat. EXPERIMENTAL)" off \
"LATEST" "Install latest version via APT package manager" off \
"LTS" "Install LTS version via APT package manager" off
Expand Down Expand Up @@ -73,7 +73,7 @@ EOF
eval "$(cat "${NPM_WIN_PROFILE}")"
fi

if [[ ${menu_choice} == *"N"* ]]; then
if [[ ${menu_choice} == *"NVERMAN"* ]]; then
echo "Ensuring we have build-essential installed"
sudo apt-get -y -q install build-essential

Expand Down Expand Up @@ -118,9 +118,11 @@ EOF
# Add npm to bash completion
sudo mkdir -p /etc/bash_completion.d
npm completion | sudo tee /etc/bash_completion.d/npm

touch "${HOME}"/.should-restart
elif [[ ${menu_choice} == *"NVM"* ]]; then
echo "Installing nvm, Node.js version manager"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

# Set NVM_DIR variable and load nvm
NVM_PATH="$(cat ${HOME}/.bashrc | grep '^export NVM_DIR=')"
Expand Down Expand Up @@ -171,10 +173,12 @@ EOF

# Add npm to bash completion
npm completion | sudo tee /etc/bash_completion.d/npm

touch "${HOME}"/.should-restart
elif [[ ${menu_choice} == *"LATEST"* ]]; then
echo "Installing latest node.js version from NodeSource repository"

major_vers=15
major_vers=16
nodesrc_url="https://deb.nodesource.com/setup_${major_vers}.x"
#curl -sL "$nodesrc_url" -o repo-install.sh
#sudo bash repo-install.sh
Expand Down
29 changes: 18 additions & 11 deletions pengwin-setup.d/pythonpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,37 @@ function install_pyenv() {

if [[ -f "${HOME}"/.bashrc && $(grep -c '^[^#]*\bPATH.*/.pyenv/bin' "${HOME}"/.bashrc) == 0 ]]; then
echo "" >>"${HOME}"/.bashrc
echo "export PATH=\"\${HOME}/.pyenv/bin:\${PATH}\"" >>"${HOME}"/.bashrc
echo "export PYENV_ROOT=\"\${HOME}/.pyenv\"" >>"${HOME}"/.bashrc
echo "export PATH=\"\${PYENV_ROOT}/bin:\${PATH}\"" >>"${HOME}"/.bashrc
echo "eval \"\$(pyenv init --path)\"" >>"${HOME}"/.bashrc
echo "eval \"\$(pyenv init -)\"" >>"${HOME}"/.bashrc
echo "eval \"\$(pyenv virtualenv-init -)\"" >>"${HOME}"/.bashrc
fi

if [[ -f "${HOME}"/.zshrc && $(grep -c '^[^#]*\bPATH.*/.pyenv/bin' "${HOME}"/.zshrc) == 0 ]]; then
echo "" >>"${HOME}"/.zshrc
echo "export PATH=\"${HOME}/.pyenv/bin:\$PATH\"" >>"${HOME}"/.zshrc
echo "export PYENV_ROOT=\"\${HOME}/.pyenv\"" >>"${HOME}"/.zshrc
echo "export PATH=\"\${PYENV_ROOT}/bin:\${PATH}\"" >>"${HOME}"/.zshrc
echo "eval \"\$(pyenv init --path)\"" >>"${HOME}"/.zshrc
echo "eval \"\$(pyenv init -)\"" >>"${HOME}"/.zshrc
echo "eval \"\$(pyenv virtualenv-init -)\"" >>"${HOME}"/.zshrc
fi

# shellcheck disable=SC2002
if [[ -d "${HOME}"/.config/fish && $(cat "${HOME}"/.config/fish/config.fish 2>/dev/null | grep -c '^[^#]*\bPATH.*/.pyenv/bin') == 0 ]]; then
echo "" >>"${HOME}"/.config/fish/config.fish
echo "set -x PATH \"${HOME}/.pyenv/bin\" \$PATH" >>"${HOME}"/.config/fish/config.fish
echo "set -x PYENV_ROOT \"${HOME}/.pyenv\"" >>"${HOME}"/.config/fish/config.fish
echo "set -x PATH \"${PYENV_ROOT}/bin\" \$PATH" >>"${HOME}"/.config/fish/config.fish
echo 'status --is-interactive; and pyenv init --path| source' >>"${HOME}"/.config/fish/config.fish
echo 'status --is-interactive; and pyenv init -| source' >>"${HOME}"/.config/fish/config.fish
echo 'status --is-interactive; and pyenv virtualenv-init -| source' >>"${HOME}"/.config/fish/config.fish
fi

echo "installing Python 3.9"
export PATH="${HOME}/.pyenv/bin:$PATH"
echo "Installing Python 3.9"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv install -s 3.9.4
pyenv global 3.9.4

pyenv install -s 3.9.6
pyenv global 3.9.6

touch "${HOME}"/.should-restart

Expand Down Expand Up @@ -99,6 +104,8 @@ function main() {
3>&1 1>&2 2>&3
)

echo "Selected:" "${menu_choice}"

if [[ ${menu_choice} == "CANCELLED" ]]; then
return 1
fi
Expand Down
1 change: 1 addition & 0 deletions pengwin-setup.d/uninstall/guilib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function main() {
sudo_rem_file "/etc/dbus-1/session.conf"
sudo_rem_file "/usr/share/dbus-1/session.conf"
sudo_rem_file "/etc/profile.d/dbus.sh"
sudo_rem_file "${__fish_sysconf_dir:=/etc/fish/conf.d}/dbus.fish"

remove_package xclip gnome-themes-standard gtk2-engines-murrine dbus dbus-x11 mesa-utils libqt5core5a binutils libnss3 libegl1-mesa
}
Expand Down
1 change: 1 addition & 0 deletions pengwin-setup.d/uninstall/hidpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function main() {

echo "Uninstalling Qt and GTK HiDPI modifications"
sudo_rem_file "/etc/profile.d/hidpi.sh"
sudo_rem_file "${__fish_sysconf_dir:=/etc/fish/conf.d}/hidpi.fish"

}

Expand Down
24 changes: 12 additions & 12 deletions pengwin-setup.d/uninstall/lamp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
# shellcheck source=./uninstall-common.sh
source "$(dirname "$0")/uninstall-common.sh" "$@"

function main()
{
function main() {

echo "Uninstalling LAMP stack"
echo "Uninstalling LAMP stack"

sudo_rem_file "/etc/profile.d/start-lamp.sh"
sudo_rem_file "/etc/sudoers.d/start-lamp"
sudo_rem_file "/etc/profile.d/start-lamp.sh"
sudo_rem_file "/etc/sudoers.d/start-lamp"

sudo_rem_file "/usr/bin/start-lamp"
sudo_rem_file "/usr/bin/start-lamp"

remove_package "mariadb-server" "mariadb-client" "apache2" "apache2-utils" "php" "libapache2-mod-php" "php-cli" "php-fpm" "php-json" "php-pdo" "php-mysql" "php-zip" "php-gd" "php-mbstring" "php-curl" "php-xml" "php-pear" "php-bcmath"
remove_package "mariadb-server" "mariadb-client" "mariadb-backup" "apache2" "apache2-utils" "php" "libapache2-mod-php" "php-cli" "php-fpm" "php-json" "php-pdo" "php-mysql" "php-zip" "php-gd" "php-mbstring" "php-curl" "php-xml" "php-pear" "php-bcmath" "libdbi-perl"

sudo sed -i '/mariadb/d' /etc/apt/sources.list
sudo_rem_file "/etc/apt/trusted.gpg.d/mariadb-keyring-2019.gpg"
sudo_rem_file "/var/www/html/phpinfo.php"
sudo sed -i '/mariadb/d' /etc/apt/sources.list
sudo_rem_file "/etc/apt/trusted.gpg.d/mariadb-keyring-2019.gpg"
sudo_rem_file "/var/www/html/phpinfo.php"

sudo apt-get autoremove
}

if show_warning "LAMP stack" "$@" ; then
main "$@"
if show_warning "LAMP stack" "$@"; then
main "$@"
fi
13 changes: 10 additions & 3 deletions pengwin-setup.d/uninstall/pyenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
# shellcheck source=./uninstall-common.sh
source "$(dirname "$0")/uninstall-common.sh" "$@"

line_rgx='^[^#]*\bPATH.*/.pyenv/bin'
line2_rgx='^[^#]*\bpyenv init -'
line3_rgx='^[^#]*\bpyenv virtualenv-init -'
line_rgx='^[^#]*\bPYENV_ROOT.*/.pyenv'
line2_rgx='^[^#]*\bPATH.*PYENV_ROOT.*/bin'
line3_rgx='^[^#]*\bpyenv init --path'
line4_rgx='^[^#]*\bpyenv init -'
line5_rgx='^[^#]*\bPATH.*/.pyenv/bin'
line6_rgx='^[^#]*\bpyenv virtualenv-init -'


function multiclean_file() {

Expand All @@ -14,6 +18,9 @@ function multiclean_file() {
clean_file "$1" "$line_rgx"
clean_file "$1" "$line2_rgx"
clean_file "$1" "$line3_rgx"
clean_file "$1" "$line4_rgx"
clean_file "$1" "$line5_rgx"
clean_file "$1" "$line6_rgx"
fi

}
Expand Down
1 change: 1 addition & 0 deletions pengwin-setup.d/uninstall/vcxsrv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function main() {

echo "Removing PATH modifier..."
sudo_rem_file "/etc/profile.d/01-vcxsrv.sh"
sudo_rem_file "${__fish_sysconf_dir:=/etc/fish/conf.d}/01-vcxsrv.fish"

}

Expand Down
1 change: 1 addition & 0 deletions pengwin-setup.d/uninstall/x410.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ source "$(dirname "$0")/uninstall-common.sh" "$@"
function main() {
echo "Removing PATH modifier..."
sudo_rem_file "/etc/profile.d/02-x410.sh"
sudo_rem_file "${__fish_sysconf_dir:=/etc/fish/conf.d}/02-x410.fish"
}

if show_warning "x410" "$@"; then
Expand Down
Loading

0 comments on commit dca38b3

Please sign in to comment.