Skip to content

Instantly share code, notes, and snippets.

@taking
Last active December 17, 2022 15:57
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save taking/29cedbf32561b108d98b8d5dc8cc3cd7 to your computer and use it in GitHub Desktop.
Save taking/29cedbf32561b108d98b8d5dc8cc3cd7 to your computer and use it in GitHub Desktop.
#/bin/bash
## taking.kr (webmaster@taking.kr)
## 2019-06-11
###########################################
read -p "hostname (ex taking.kr): " uhost
read -p "new username: " uname
read -p "$uname's Password: " upasswd
encrypt_pass=$(perl -e 'print crypt($ARGV[0], "password")' $upasswd)
############ nameserver setting ###############
cat <<EOT > /etc/resolv.conf
search UHOSTNAME
;KT DNS
nameserver 168.126.63.1
nameserver 168.126.63.2
;Google DNS
;nameserver 8.8.8.8
;nameserver 8.8.4.4
; LG Uplus
;nameserver 180.182.54.1
;nameserver 210.94.0.73
EOT
sed -i "s/UHOSTNAME/$uhost/g" /etc/resolv.conf
echo 'Edit /etc/resolv.conf Success'
############ language change ###############
localedef -c -i ko_KR -f UTF-8 ko_KR.utf8
localectl set-locale LANG=ko_KR.utf8
service network restart
echo 'service network restart Success'
############### Timezone ###################
timedatectl set-timezone Asia/Seoul
echo 'timezone Change Success'
############ hostname change ###############
hostnamectl set-hostname $uhost
echo 'Hostname Change Success'
###########################################
########### Source 저장소 변경 ##############
###########################################
echo -e "1. Source 저장소 변경 중"
cat << 'EOT' > /etc/apt/source.list
# add
deb http://download.proxmox.com/debian/pve stretch pve-no-subscription
# edit
deb http://ftp.daumkakao.com/debian stretch main contrib
deb http://ftp.daumkakao.com/debian stretch-updates main contrib
# old
# deb http://ftp.kr.debian.org/debian stretch main contrib
# deb http://ftp.kr.debian.org/debian stretch-updates main contrib
# security updates
# edit
deb http://ftp.daumkakao.com/debian-security stretch/updates main contrib
# old
# deb http://security.debian.org stretch/updates main contrib
EOT
echo -e "#deb https://enterprise.proxmox.com/debian/pve stretch pve-enterprise\n" > /etc/apt/sources.list.d/pve-enterprise.list
###########################################
###########################################
#### update, dist-upgrade, autoremove ####
###########################################
echo -e "2. apt update, dist-upgrade, autoremove"
apt update && apt dist-upgrade -y && apt autoremove -y
apt install vim samba curl git wget -y
# apt install net-tools
pveupdate
###########################################
###########################################
################# network #################
###########################################
cat <<EOT >> /etc/network/interfaces
#subnet
up ip route add 192.168.0.100/32 dev vmbr0
up ip route add 192.168.0.101/32 dev vmbr0
up ip route add 192.168.0.102/32 dev vmbr0
up ip route add 192.168.0.103/32 dev vmbr0
up ip route add 192.168.0.104/32 dev vmbr0
up ip route add 192.168.0.105/32 dev vmbr0
up ip route add 192.168.0.106/32 dev vmbr0
up ip route add 192.168.0.107/32 dev vmbr0
EOT
###########################################
###########################################
########## external hdd (fstab) ###########
###########################################
# HDD는 fdisk -l 과 blkid 를 통해 UUID 알아내기
mkdir /500GB && mkdir /4TB && mkdir /8TB
cat <<EOT >> /etc/fstab
UUID=b495b27c-5699-4a28-99e9-61577aeae752 /500GB/ ext4 errors=remount-ro 0 1
UUID=a595e6ea-c75f-4b8f-b87c-2dc82faae8e9 /4TB/ ext4 errors=remount-ro 0 1
UUID=6782ec7b-af99-4ede-93df-83a50ec9e1a4 /8TB/ ext4 errors=remount-ro 0 1
EOT
mount -a
###########################################
################ user add #################
###########################################
useradd -m -p $encrypt_pass $uname
cat <<EOT >> /etc/sudoers
USERNAME ALL=(ALL) NOPASSWD: ALL
EOT
sed -i "s/USERNAME/$uname/g" /etc/sudoers
###########################################
############# samba setting ###############
###########################################
groupadd sambashare
usermod -G sambashare $uname
smbpasswd -a $uname
cp /etc/samba/smb.conf /etc/samba/smb.conf-dist
cat <<EOT > /etc/samba/smb.conf
#======================= Global Settings =======================
[global]
workgroup = WORKGROUP
dns proxy = no
log file = /var/log/samba/log.%m
max log size = 1000
syslog only = no
syslog = 0
panic action = usr/share/samba/panic-action %d
####### Authentication ########
server role = standalone server
passdb backend = tdbsam
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
map to guest = bad user
usershare allow guests = no
#======================= Share Definitions =======================
[homes]
comment = Home Directories
browseable = no
writable = yes
valid users = %S
[500GB]
comment = 500GB HDD
browseable = yes
path = /500GB/
read only = no
writable = yes
create mask = 0755
directory mask = 0755
valid users = @sambashare
veto files = /._*/.DS_Store/lost+found/Thumbs.db/desktop.ini/DESKTOP.INI/*.tmp/
delete veto files = yes
[4TB]
comment = 4TB HDD
browseable = yes
path = /4TB/
read only = no
writable = yes
create mask = 0755
directory mask = 0755
valid users = @sambashare
veto files = /._*/.DS_Store/lost+found/Thumbs.db/desktop.ini/DESKTOP.INI/*.tmp/
delete veto files = yes
[8TB]
comment = 8TB HDD
browseable = yes
path = /8TB/
read only = no
writable = yes
create mask = 0755
directory mask = 0755
valid users = @sambashare
veto files = /._*/.DS_Store/lost+found/Thumbs.db/desktop.ini/DESKTOP.INI/*.tmp/
delete veto files = yes
------------------------------------------------------------------------
EOT
service smbd restart
service smbd status
############# openssh setting #############
sed -i 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config
sed -i 's/\#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config
sed -i 's/\#ListenAddress 0\.0\.0\.0/ListenAddress 0\.0\.0\.0/g' /etc/ssh/sshd_config
sed -i 's/\#UseDNS yes/UseDNS no/g' /etc/ssh/sshd_config
sed -i 's/\X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config
sed -i 's/\#X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config
cat <<EOT >> /etc/ssh/sshd_config
AllowUsers USERNAME
ClientAliveInterval 3600
ClientAliveCountMax 120
EOT
sed -i "s/USERNAME/$uname/g" /etc/ssh/sshd_config
echo 'Edit /etc/ssh/sshd_config'
systemctl enable sshd.service
service sshd restart
echo 'service sshd restart Success'
###########################################
############### ZSH Setup #################
###########################################
apt install zsh -y && chsh -s `which zsh`
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
git clone https://github.com/powerline/fonts.git && ./fonts/install.sh
cd $HOME/.oh-my-zsh/custom/plugins && git clone https://github.com/zsh-users/zsh-syntax-highlighting.git && git clone https://github.com/zsh-users/zsh-autosuggestions && git clone https://github.com/djui/alias-tips.git
###########################################
############## zsh setting ################
###########################################
wget -O $HOME/.zshrc 'https://gist.githubusercontent.com/taking/1a03b19d580dda6376300d865b19b443/raw/3dd646069a6029012e1a0829b4f3c86e7924ca6d/.zshrc%2520(linux)'
chsh -s `which zsh`
###########################################
######## new account zsh setting ##########
###########################################
cp $HOME/.zshrc /home/$uname/
cp -r $HOME/.oh-my-zsh /home/$uname/
chown -R $uname:$uname /home/$uname/
su -c 'chsh -s `which zsh`' - $uname
###########################################
############## vim Setting ################
###########################################
git clone https://github.com/VundleVim/Vundle.vim.git $HOME/.vim/bundle/Vundle.vim
mkdir $HOME/.vim/colors/
curl -G https://raw.githubusercontent.com/ErichDonGubler/vim-sublime-monokai/master/colors/sublimemonokai.vim -o $HOME/.vim/colors/sublimemonokai.vim
wget -O $HOME/.vimrc https://gist.github.com/taking/2d762c0d0a63120ace2fa3b87bf262e5/raw/0dbfec9b4796ae7ff34984f72025319cdef6dbb8/.vimrc
vim +PluginInstall +qall
cp $HOME/.vimrc /home/$uname/
cp -r $HOME/.vim /home/$uname/
chown -R $uname:$uname /home/$uname/
su -c 'vim +PluginInstall +qall' - $uname
echo '설정 완료 - 재부팅 하세요.\n'
#reboot
#/bin/bash
## taking.kr (webmaster@taking.kr)
## 2019-06-11
###########################################
############### Docker 설치 ###############
###########################################
echo 'DOcker 설치 시작\n'
apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
apt update
apt-cache policy docker-ce
apt install docker-ce
service docker status
systemctl enable docker
echo 'Docker 설치 완료.\n'
###########################################
########### Docker-compose 설치 ############
###########################################
curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
###########################################
############# Portainer 설치 ##############
###########################################
docker volume create portainer_data
docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
echo 'Portainer 접속 주소:' `hostname --ip-address`':9000'
@taking
Copy link
Author

taking commented Jun 11, 2019

docker-compose

Gitea

version: '2'
services:
  web:
    container_name: taking.kr_gitea
    image: gitea/gitea:latest
    restart: always
    ports:
      - "9001:3000"
      - "2224:22"
    volumes:
      - './data:/data'
    depends_on:
      - db
  db:
    image: mariadb:10
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=비밀번호 입력
      - MYSQL_DATABASE=데이터베이스명 입력
      - MYSQL_USER=사용자 입력
      - MYSQL_PASSWORD=비밀번호 입력
    volumes:
      - ./db/:/var/lib/mysql

Gitlab-CE

version: '2'
services:
   web:
   container_name: taking.kr_gitlab
   image: 'gitlab/gitlab-ce:latest'
   restart: always
   hostname: 'repo.taking.kr'
   container_name: gitlab
   ports:
       - '9001:80'
       - '9002:443'
       - '2224:22'
   volumes:
       - './config:/etc/gitlab'
       - './logs:/var/log/gitlab'
       - './data:/var/opt/gitlab'
       - './backups:/var/opt/gitlab/backups' # 백업 폴더 추가

Theia

version: '2'
services:
  web:
    container_name: taking.kr_theia
    image: theiaide/theia-full:next
    restart: always
    ports:
      - "9998:3000"
    volumes:
      - ./Data:/home/project/:rw

Nextcloud

version: '3'
services:
  web:
     container_name: taking.kr_nextcloud
     image: linuxserver/nextcloud:latest
     restart: always
     environment:
         - PUID=1000
         - PGID=1000
         - TZ=Asia/Seoul
     ports:
         - "9998:3000"
     volumes:
         - ./nextcloud/config:/config
         - ./nextcloud/data:/data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment