Skip to content

Instantly share code, notes, and snippets.

@Madh93
Last active May 16, 2018 19:21
Show Gist options
  • Save Madh93/d1fdaea15466c2e8bc979b8898d52d05 to your computer and use it in GitHub Desktop.
Save Madh93/d1fdaea15466c2e8bc979b8898d52d05 to your computer and use it in GitHub Desktop.
Scaleway scripts
#! /bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 2>&1
exit 1
fi
MY_USER=migue
# Create user
adduser $MY_USER
gpasswd -a $MY_USER sudo
# Edit SSH configuration
cp -r /root/.ssh /home/$MY_USER
chown -R $MY_USER:$MY_USER /home/$MY_USER/.ssh
sed -i 's/PermitRootLogin/PermitRootLogin no#/g' /etc/ssh/sshd_config
sed -i 's/PasswordAuthentication/PasswordAuthentication no#/g' /etc/ssh/sshd_config
sed -i 's/X11Forwarding/X11Forwarding no#/g' /etc/ssh/sshd_config
sed -i 's/LoginGraceTime/LoginGraceTime 30#/g' /etc/ssh/sshd_config
echo "\n" >> /etc/ssh/sshd_config
echo 'ClientAliveInterval 120' >> /etc/ssh/sshd_config
echo 'ClientAliveCountMax 2' >> /etc/ssh/sshd_config
echo 'MaxStartUps 3' >> /etc/ssh/sshd_config
echo 'AllowTcpForwarding no' >> /etc/ssh/sshd_config
systemctl restart ssh
# Set Time Zone
timedatectl set-timezone 'Atlantic/Canary'
# Update packages
apt update && apt upgrade -y && apt-get autoremove -y
# Install useful packages
apt install -y fail2ban htop
#! /bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 2>&1 && exit 1
fi
# Custom settings
RUBY_MAJOR="2"
RUBY_MINOR="4"
RUBY_PATCH="1"
RUBY_VERSION="$RUBY_MAJOR.$RUBY_MINOR.$RUBY_PATCH"
MAKE_FLAGS="-j$(expr $(nproc) \+ 1)"
# Update system
apt-get update && apt-get upgrade -y
# Install dependencies for Ruby
apt-get install -y \
autoconf \
bison \
build-essential \
libssl-dev \
libyaml-dev \
libreadline6-dev \
zlib1g-dev \
libncurses5-dev \
libffi-dev \
libgdbm3 \
libgdbm-dev
# Download Ruby source code
cd /tmp
wget https://cache.ruby-lang.org/pub/ruby/ruby-$RUBY_VERSION.tar.gz
tar -xvzf ruby-$RUBY_VERSION.tar.gz
cp -r ruby-$RUBY_VERSION /usr/src
# Prepare Ruby building
cd /usr/src/ruby-$RUBY_VERSION
./configure \
--enable-shared \
--disable-install-doc \
--disable-install-rdoc \
--disable-install-capi
# Build Ruby
make $MAKE_FLAGS
# Install Ruby
make install
# Install Chef
gem install chef --no-ri --no-rdoc
# Clean
apt-get autoclean -y && apt-get autoremove -y
rm -rf \
/tmp/ruby-$RUBY_VERSION \
/tmp/ruby-$RUBY_VERSION.tar.gz \
/usr/src/ruby-$RUBY_VERSION
echo "All done!"
#! /bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 2>&1
exit 1
fi
MY_USER=migue
# Installing dependencies and add docker repository
apt update
apt upgrade -y
apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
echo "deb [arch=armhf] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
##Installing Docker
apt update
apt install -y docker-ce
## After installing Docker
#groupadd docker
usermod -aG docker $MY_USER
systemctl enable docker
#! /bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 2>&1
exit 1
fi
MY_USER="migue"
# Prepare directories
mkdir -p /usr/local/bin
mkdir -p /home/$MY_USER/.pihole
# Get scripts
wget https://gist.githubusercontent.com/Madh93/123b43ede07d0f61d10a4c5eaa80dc22/raw/7c7f0f7a9015f3fc53ee3dea3e7cbc459d119758/pihole.sh -O /usr/local/bin/pihole
wget https://gist.githubusercontent.com/Madh93/123b43ede07d0f61d10a4c5eaa80dc22/raw/7c7f0f7a9015f3fc53ee3dea3e7cbc459d119758/pihole.service -O /etc/systemd/system/pihole.service
# Permissions
chmod +x /usr/local/bin/pihole
chown -R $MY_USER:$MY_USER /usr/local/bin
chown -R $MY_USER:$MY_USER /home/$MY_USER/.pihole
# Launch pihole
systemctl start pihole.service
systemctl enable pihole.service

Scaleway scripts

  • Initial setup
  • Install Chef
  • Install Docker
  • Install Pi-hole
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment