Skip to content

Instantly share code, notes, and snippets.

@5lx
Last active December 25, 2021 16:05
Show Gist options
  • Select an option

  • Save 5lx/3c25315cf02f7a8919d3129d57a45dc9 to your computer and use it in GitHub Desktop.

Select an option

Save 5lx/3c25315cf02f7a8919d3129d57a45dc9 to your computer and use it in GitHub Desktop.

Revisions

  1. 5lx revised this gist Dec 25, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -50,6 +50,7 @@ set -g history-limit 100000
    set -g mouse on
    set -g default-terminal "screen-256color"
    # fix less/man mouse scrolling when enabled the mouse mode in tmux
    tmux_commands_with_legacy_scroll="nano less more man git"
    bind-key -T root WheelUpPane \
  2. 5lx revised this gist Dec 25, 2021. 1 changed file with 20 additions and 2 deletions.
    22 changes: 20 additions & 2 deletions fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -44,8 +44,26 @@ cd
    git clone https://github.com/gpakosz/.tmux.git
    ln -s -f .tmux/.tmux.conf
    cp .tmux/.tmux.conf.local .
    echo "set -g history-limit 100000" >> .tmux.conf.local
    echo "set -g mouse on" >> .tmux.conf.local

    cat <<EOF >> .tmux.conf.local
    set -g history-limit 100000
    set -g mouse on
    set -g default-terminal "screen-256color"
    tmux_commands_with_legacy_scroll="nano less more man git"
    bind-key -T root WheelUpPane \
    if-shell -Ft= '#{?mouse_any_flag,1,#{pane_in_mode}}' \
    'send -Mt=' \
    'if-shell -t= "#{?alternate_on,true,false} || echo \"#{tmux_commands_with_legacy_scroll}\" | grep -q \"#{pane_current_command}\"" \
    "send -t= Up" "copy-mode -et="'
    bind-key -T root WheelDownPane \
    if-shell -Ft = '#{?pane_in_mode,1,#{mouse_any_flag}}' \
    'send -Mt=' \
    'if-shell -t= "#{?alternate_on,true,false} || echo \"#{tmux_commands_with_legacy_scroll}\" | grep -q \"#{pane_current_command}\"" \
    "send -t= Down" "send -Mt="'
    EOF

    # vim
    echo "set ttymouse=xterm2" >> .vimrc
  3. 5lx revised this gist Jan 22, 2019. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -56,8 +56,11 @@ cd
    sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
    ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
    git clone https://github.com/zsh-users/zsh-autosuggestions.git \
    ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
    # sed -i "s/^\(ZSH_THEME\s*=\s*\).*\$/\1\"agnoster\"/" .zshrc
    sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ zsh-syntax-highlighting/" .zshrc
    sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ zsh-autosuggestions/" .zshrc
    sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ colored-man-pages/" .zshrc
    # need these two line to fix zsh-completion command duplicated
    # Ref: https://github.com/sindresorhus/pure/issues/300#issuecomment-328744993
  4. 5lx revised this gist Jan 9, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # Resize. Suppose /dev/sda2 (LVM)
    pvresize /dev/sda2
    lvextend /dev/mapper/fedora-root -l+100%FREE
    # assuming ext2/3/4
    # For ext2/3/4
    resize2fs /dev/mapper/fedora-root
    # For xfs
    xfs_growfs /
  5. 5lx revised this gist Jan 9, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Resize. Suppose /dev/sda2 is the LVM
    # Resize. Suppose /dev/sda2 (LVM)
    pvresize /dev/sda2
    lvextend /dev/mapper/fedora-root -l+100%FREE
    # assuming ext2/3/4
  6. 5lx revised this gist Sep 10, 2018. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -59,6 +59,10 @@ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
    # sed -i "s/^\(ZSH_THEME\s*=\s*\).*\$/\1\"agnoster\"/" .zshrc
    sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ zsh-syntax-highlighting/" .zshrc
    sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ colored-man-pages/" .zshrc
    # need these two line to fix zsh-completion command duplicated
    # Ref: https://github.com/sindresorhus/pure/issues/300#issuecomment-328744993
    echo "export LANG=en_US.UTF-8" >> .zshrc
    echo "export LC_ALL=en_US.UTF-8" >> .zshrc

    # conda
    wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
  7. 5lx revised this gist Jul 3, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Resize
    # Resize. Suppose /dev/sda2 is the LVM
    pvresize /dev/sda2
    lvextend /dev/mapper/fedora-root -l+100%FREE
    # assuming ext2/3/4
  8. 5lx revised this gist Jul 3, 2018. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,11 @@
    # Resize
    pvresize /dev/sda2
    lvextend /dev/mapper/fedora-root -l+100%FREE
    # assuming ext2/3/4
    resize2fs /dev/mapper/fedora-root
    # For xfs
    xfs_growfs /

    # Install Software
    sudo dnf -y update
    sudo dnf -y groupinstall "development tools"
  9. 5lx revised this gist Jun 11, 2018. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # Install Software
    sudo yum -y update
    sudo yum -y groupinstall "development tools"
    sudo yum -y install vim wget curl htop tmux bzip2 unzip net-tools zsh util-linux-user
    sudo dnf -y update
    sudo dnf -y groupinstall "development tools"
    sudo dnf -y install vim wget curl htop tmux bzip2 unzip net-tools zsh util-linux-user

    # Add ssh keys
    mkdir ~/.ssh && chmod 700 ~/.ssh
    @@ -12,7 +12,7 @@ chmod 600 ~/.ssh/authorized_keys
    echo "PermitEmptyPasswords no" | sudo tee -a /etc/ssh/sshd_config > /dev/null
    echo "PasswordAuthentication no" | sudo tee -a /etc/ssh/sshd_config > /dev/null
    echo "PermitRootLogin no" | sudo tee -a /etc/ssh/sshd_config > /dev/null
    sudo yum -y install fail2ban
    sudo dnf -y install fail2ban
    sudo cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local
    sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
    echo "[sshd]\nenabled = true" | sudo tee -a /etc/fail2ban/jail.local > /dev/null
  10. 5lx revised this gist Jun 11, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,9 @@ sudo systemctl restart sshd
    sudo systemctl enable fail2ban
    sudo systemctl start fail2ban

    # Hostname
    sudo hostnamectl set-hostname blabla

    # docker
    sudo dnf -y install dnf-plugins-core
    sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
  11. 5lx revised this gist Jun 4, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -54,4 +54,4 @@ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
    bash Miniconda3-latest-Linux-x86_64.sh
    echo "export PATH=\"/root/.miniconda3/bin:\$PATH\"" >> .zshrc

    reboot now
    sudo reboot now
  12. 5lx revised this gist Jun 4, 2018. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -9,13 +9,13 @@ curl https://github.com/5lx.keys >> ~/.ssh/authorized_keys
    chmod 600 ~/.ssh/authorized_keys

    # ssh enforce
    echo "PermitEmptyPasswords no" | sudo tee -a /etc/ssh/sshd_config
    echo "PasswordAuthentication no" | sudo tee -a /etc/ssh/sshd_config
    echo "PermitRootLogin no" | sudo tee -a /etc/ssh/sshd_config
    echo "PermitEmptyPasswords no" | sudo tee -a /etc/ssh/sshd_config > /dev/null
    echo "PasswordAuthentication no" | sudo tee -a /etc/ssh/sshd_config > /dev/null
    echo "PermitRootLogin no" | sudo tee -a /etc/ssh/sshd_config > /dev/null
    sudo yum -y install fail2ban
    sudo cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local
    sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
    echo "[sshd]\nenabled = true" | sudo tee -a /etc/fail2ban/jail.local
    echo "[sshd]\nenabled = true" | sudo tee -a /etc/fail2ban/jail.local > /dev/null
    sudo systemctl restart sshd
    sudo systemctl enable fail2ban
    sudo systemctl start fail2ban
  13. 5lx revised this gist Jun 4, 2018. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -9,13 +9,13 @@ curl https://github.com/5lx.keys >> ~/.ssh/authorized_keys
    chmod 600 ~/.ssh/authorized_keys

    # ssh enforce
    sudo echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config
    sudo echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
    sudo echo "PermitRootLogin no" >> /etc/ssh/sshd_config
    echo "PermitEmptyPasswords no" | sudo tee -a /etc/ssh/sshd_config
    echo "PasswordAuthentication no" | sudo tee -a /etc/ssh/sshd_config
    echo "PermitRootLogin no" | sudo tee -a /etc/ssh/sshd_config
    sudo yum -y install fail2ban
    sudo cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local
    sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
    sudo echo "[sshd]\nenabled = true" >> /etc/fail2ban/jail.local
    echo "[sshd]\nenabled = true" | sudo tee -a /etc/fail2ban/jail.local
    sudo systemctl restart sshd
    sudo systemctl enable fail2ban
    sudo systemctl start fail2ban
  14. 5lx revised this gist Jun 4, 2018. 1 changed file with 22 additions and 21 deletions.
    43 changes: 22 additions & 21 deletions fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -1,31 +1,32 @@
    # Install Software
    yum -y update
    yum -y groupinstall "development tools"
    yum -y install vim wget curl htop tmux bzip2 unzip net-tools zsh util-linux-user
    sudo yum -y update
    sudo yum -y groupinstall "development tools"
    sudo yum -y install vim wget curl htop tmux bzip2 unzip net-tools zsh util-linux-user

    # Add ssh keys
    mkdir /root/.ssh && chmod 700 /root/.ssh
    curl https://github.com/5lx.keys >> /root/.ssh/authorized_keys
    chmod 600 /root/.ssh/authorized_keys
    mkdir ~/.ssh && chmod 700 ~/.ssh
    curl https://github.com/5lx.keys >> ~/.ssh/authorized_keys
    chmod 600 ~/.ssh/authorized_keys

    # ssh enforce
    echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config
    echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
    yum -y install fail2ban
    cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local
    cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
    echo "[sshd]\nenabled = true" >> /etc/fail2ban/jail.local
    systemctl restart sshd
    systemctl enable fail2ban
    systemctl start fail2ban
    sudo echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config
    sudo echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
    sudo echo "PermitRootLogin no" >> /etc/ssh/sshd_config
    sudo yum -y install fail2ban
    sudo cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local
    sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
    sudo echo "[sshd]\nenabled = true" >> /etc/fail2ban/jail.local
    sudo systemctl restart sshd
    sudo systemctl enable fail2ban
    sudo systemctl start fail2ban

    # docker
    dnf -y install dnf-plugins-core
    dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
    dnf config-manager --set-enabled docker-ce-edge
    dnf -y install docker-ce
    systemctl enable docker
    systemctl start docker
    sudo dnf -y install dnf-plugins-core
    sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
    sudo dnf config-manager --set-enabled docker-ce-edge
    sudo dnf -y install docker-ce
    sudo systemctl enable docker
    sudo systemctl start docker

    # tmux
    cd
  15. 5lx revised this gist Jun 3, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # Install Software
    yum -y update
    yum -y groupinstall "development tools"
    yum -y install vim wget curl htop tmux bzip2 unzip net-tools zsh
    yum -y install vim wget curl htop tmux bzip2 unzip net-tools zsh util-linux-user

    # Add ssh keys
    mkdir /root/.ssh && chmod 700 /root/.ssh
  16. 5lx revised this gist Jun 3, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,7 @@ echo "set -g mouse on" >> .tmux.conf.local

    # vim
    echo "set ttymouse=xterm2" >> .vimrc
    echp "set mouse=a" >> .vimrc
    echo "set mouse=a" >> .vimrc

    # zsh
    cd
  17. 5lx revised this gist Jun 2, 2018. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -11,8 +11,11 @@ chmod 600 /root/.ssh/authorized_keys
    # ssh enforce
    echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config
    echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
    systemctl restart sshd
    yum -y install fail2ban
    cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local
    cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
    echo "[sshd]\nenabled = true" >> /etc/fail2ban/jail.local
    systemctl restart sshd
    systemctl enable fail2ban
    systemctl start fail2ban

  18. 5lx revised this gist Jun 2, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,7 @@ systemctl start fail2ban
    # docker
    dnf -y install dnf-plugins-core
    dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
    dnf config-manager --set-enabled docker-ce-edge
    dnf -y install docker-ce
    systemctl enable docker
    systemctl start docker
    @@ -44,4 +45,9 @@ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
    sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ zsh-syntax-highlighting/" .zshrc
    sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ colored-man-pages/" .zshrc

    # conda
    wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
    bash Miniconda3-latest-Linux-x86_64.sh
    echo "export PATH=\"/root/.miniconda3/bin:\$PATH\"" >> .zshrc

    reboot now
  19. 5lx revised this gist Jun 2, 2018. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,13 @@ mkdir /root/.ssh && chmod 700 /root/.ssh
    curl https://github.com/5lx.keys >> /root/.ssh/authorized_keys
    chmod 600 /root/.ssh/authorized_keys

    # ssh enforce
    echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config
    echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
    systemctl restart sshd
    yum -y install fail2ban
    systemctl enable fail2ban
    systemctl start fail2ban

    # docker
    dnf -y install dnf-plugins-core
    @@ -39,4 +44,4 @@ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
    sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ zsh-syntax-highlighting/" .zshrc
    sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ colored-man-pages/" .zshrc

    source .zshrc
    reboot now
  20. 5lx revised this gist Jun 2, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,7 @@ curl https://github.com/5lx.keys >> /root/.ssh/authorized_keys
    chmod 600 /root/.ssh/authorized_keys

    echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
    systemctl restart sshd

    # docker
    dnf -y install dnf-plugins-core
    @@ -38,4 +39,4 @@ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
    sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ zsh-syntax-highlighting/" .zshrc
    sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ colored-man-pages/" .zshrc


    source .zshrc
  21. 5lx revised this gist Jun 2, 2018. 1 changed file with 26 additions and 1 deletion.
    27 changes: 26 additions & 1 deletion fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -13,4 +13,29 @@ echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
    # docker
    dnf -y install dnf-plugins-core
    dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
    dnf install docker-ce
    dnf -y install docker-ce
    systemctl enable docker
    systemctl start docker

    # tmux
    cd
    git clone https://github.com/gpakosz/.tmux.git
    ln -s -f .tmux/.tmux.conf
    cp .tmux/.tmux.conf.local .
    echo "set -g history-limit 100000" >> .tmux.conf.local
    echo "set -g mouse on" >> .tmux.conf.local

    # vim
    echo "set ttymouse=xterm2" >> .vimrc
    echp "set mouse=a" >> .vimrc

    # zsh
    cd
    sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
    ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
    # sed -i "s/^\(ZSH_THEME\s*=\s*\).*\$/\1\"agnoster\"/" .zshrc
    sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ zsh-syntax-highlighting/" .zshrc
    sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ colored-man-pages/" .zshrc


  22. 5lx created this gist Jun 2, 2018.
    16 changes: 16 additions & 0 deletions fedora_startup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # Install Software
    yum -y update
    yum -y groupinstall "development tools"
    yum -y install vim wget curl htop tmux bzip2 unzip net-tools zsh

    # Add ssh keys
    mkdir /root/.ssh && chmod 700 /root/.ssh
    curl https://github.com/5lx.keys >> /root/.ssh/authorized_keys
    chmod 600 /root/.ssh/authorized_keys

    echo "PasswordAuthentication no" >> /etc/ssh/sshd_config

    # docker
    dnf -y install dnf-plugins-core
    dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
    dnf install docker-ce