#!/bin/bash
###########################################################
#
# Armbian 최적화 스크립트 - https://www.armbian.com/
# Release 2023.05.01.
#
# 이 스크립트는 반드시 인터넷이 가능한 상태에서
# root/1234 계정으로 SSH 로그인하여 실행해야 한다.
#
###########################################################
CURRENT_DIR=$(pwd)
TIMESTAMP=$(date "+%Y%m%d_%H%M%S")
APTCMD="apt"
# Let's encrypt
LETSENCRYPT_DOMAIN="hasu0707.duckdns.org"
# https://download.pydio.com/pub/core/archives/
PYDIO_VERSION="8.2.5"
PYDIO_DB_PW="pydio"
# http://extplorer.net/projects/extplorer/files
EXTPLORER_VERSION="2.1.15"
# 설치 스위치
NEW_USER="armbian"
NEW_GROUP="${NEW_USER}"
NEW_USER_HOME="/home/${NEW_USER}"
STORAGE_MOUNT_DIR="/mnt/usbdisk"
AUTOFS_DIR="/mnt/usbdisk"
WWW_DIR="/var/www"
SET_NETWORK_CONFIG=1
USE_APACHE2=1
USE_WEBDAV=1
USE_MARIADB=1
USE_PHP=1
USE_PYDIO=0
USE_EXTPLORER=0
USE_SAMBA=1
USE_TRANSMISSION=0
USE_XWINDOW=1
USE_VSFTPD=1
USE_NFS_SERVER=1
USE_XRDP=1
USE_VNC_SERVER=0
USE_BT_AUDIO=0
USE_PLEXMEDIASERVER=0
USE_LETSENCRYPT=0
USE_DOCKER=1
USE_BITWARDEN=0
# LXDE or XFCE or GNOME
DESKTOP_ENVIRONMENT="LXDE"
HANGUL_IME="ibus"
DOCKER_ARCH="armhf"
HTTP_PORT=80
WEBDAV_PORT=5005
WIFI_ENABLE=1
setup_opizero() {
echo "###########################################################"
echo "#"
echo "# Orange PI Zero LTS"
echo "#"
echo "###########################################################"
BOARD_NAME="Orange Pi Zero"
BOARD_NAME_SHORT="opizero"
USE_BT_AUDIO=1
ETH0_IP=10.10.10.106
ETH0_NM=255.255.255.0
GATEWAY=10.10.10.254
WIFI_SSID="eSecuVali"
WIFI_PW="20271095"
#ETH0_IP=192.168.1.22
#ETH0_NM=255.255.255.0
#GATEWAY=192.168.1.1
#WIFI_SSID="IEEE_802.11_BGN"
#WIFI_PW="01086023358"
MY_SITE=${BOARD_NAME_SHORT}
DNS_SERVER1="8.8.8.8"
DNS_SERVER2="8.8.4.4"
}
setup_opizero2() {
echo "###########################################################"
echo "#"
echo "# Orange PI Zero2"
echo "#"
echo "###########################################################"
DOCKER_ARCH="arm64"
BOARD_NAME="Orange Pi Zero2"
BOARD_NAME_SHORT="opizero2"
USE_XRDP=0
USE_VNC_SERVER=1
ETH0_IP=10.10.10.108
ETH0_NM=255.255.255.0
GATEWAY=10.10.10.254
WIFI_SSID="eSecuVali_5G"
WIFI_PW="20271095"
#ETH0_IP=192.168.1.20
#ETH0_NM=255.255.255.0
#GATEWAY=192.168.1.1
#WIFI_SSID="IEEE_802.11_NAC"
#WIFI_PW="01086023358"
MY_SITE=${BOARD_NAME_SHORT}
DNS_SERVER1="8.8.8.8"
DNS_SERVER2="8.8.4.4"
# 이 패키지를 업데이트하면 부팅 불가하여 업데이트에서 제외한다.
apt-mark hold armbian-bsp-cli-orangepizero2
}
setup_odroidhc2() {
echo "###########################################################"
echo "#"
echo "# Odroid HC2 설치 준비"
echo "#"
echo "###########################################################"
STORAGE_MOUNT_DIR="/mnt/sata"
USE_LETSENCRYPT=1
USE_BITWARDEN=1
BOARD_NAME="ODROID HC2"
BOARD_NAME_SHORT="odroid_hc2"
WIFI_ENABLE=0
ETH0_IP=192.168.1.10
ETH0_NM=255.255.255.0
GATEWAY=192.168.1.1
WIFI_SSID="IEEE_802.11_BGN"
WIFI_PW="01086023358"
MY_SITE=${BOARD_NAME_SHORT}
DNS_SERVER1="8.8.8.8"
DNS_SERVER2="8.8.4.4"
}
check_board_name() {
echo "###########################################################"
echo "#"
echo "# 어떤 보드인지 체크한다."
echo "#"
echo "###########################################################"
RELEASE_FILE="/etc/armbian-release"
grep "Orange Pi Zero2" ${RELEASE_FILE} > /dev/null
if [ $? -eq 0 ]
then
echo "This board is Orange Pi Zero 2"
setup_opizero2
return
fi
grep "Orange Pi Zero" ${RELEASE_FILE} > /dev/null
if [ $? -eq 0 ]
then
echo "This board is Orange Pi Zero LTS"
setup_opizero
return
fi
grep "Odroid XU4" ${RELEASE_FILE} > /dev/null
if [ $? -eq 0 ]
then
echo "This board is ODROID HC2"
setup_odroidhc2
return
else
echo "ERROR: Unknown board."
exit 1
fi
}
get_system_ip_addr() {
echo "###########################################################"
echo "# 시스템 IP주소 알아내기"
echo "###########################################################"
SYSTEM_IP_ADDR=$(hostname -I | awk '{print $1}')
if [ -z ${SYSTEM_IP_ADDR} ]
then
echo "ERROR: Unknown IP Address."
exit
fi
echo "ip addr: ${SYSTEM_IP_ADDR}"
}
get_system_if_name() {
echo "###########################################################"
echo "# 시스템 인터페이스명 알아내기"
echo "###########################################################"
SYSTEM_IF_NAME=$(ls -1 /sys/class/net/ | awk '{ if ( $1 != "lo" && $1 != "docker0") print $1 }' | head -n 1)
if [ -z ${SYSTEM_IF_NAME} ]
then
echo "ERROR: Unknown interface name."
exit
fi
echo "if name: ${SYSTEM_IF_NAME}"
}
deb_clean() {
echo "###########################################################"
echo "#"
echo "# apt의 불필요한 패키지 정리 및 디스크 공간 확보"
echo "#"
echo "###########################################################"
sync
${APTCMD} -y clean
${APTCMD} -y -f autoremove --purge
${APTCMD} -y autoclean
sync
}
dpkg_init() {
echo "###########################################################"
echo "#"
echo "# dpkg 패키지 관리자 초기화"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
rm -f /var/lib/dpkg/lock
dpkg --configure -a
}
set_ubuntu_repo() {
echo "###########################################################"
echo "#"
echo "# Ubuntu 레포지터리 변경"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
cp -f /etc/apt/sources.list /etc/apt/sources.list.${TIMESTAMP}
sed -i "s/http:\/\/mirrors.tuna.tsinghua.edu.cn\/ubuntu-ports/http:\/\/ports.ubuntu.com/g" /etc/apt/sources.list
}
set_locale() {
echo "###########################################################"
echo "#"
echo "# 로케일 설정"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
localedef -v -c -i ko_KR -f UTF-8 ko_KR.UTF-8
locale-gen "ko_KR.UTF-8"
update-locale LC_ALL="ko_KR.UTF-8" LANG="ko_KR.UTF-8" LANGUAGE="ko_KR:ko:en_US:en" LC_MESSAGES="POSIX"
sed -i "s/# set convert-meta off/set convert-meta off/g" /etc/inputrc
}
init_sdcard() {
echo "###########################################################"
echo "#"
echo "# sdcard 초기화"
echo "# /dev/mmcblk0 : sdcard"
echo "# dd if=/dev/zero of=/dev/mmcblk1 bs=512 count=1"
echo "#"
echo "###########################################################"
dd if=/dev/zero of=/dev/mmcblk0 bs=4096 count=1
}
set_timezone() {
echo "###########################################################"
echo "#"
echo "# 타임존 셋팅"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
echo "Asia/Seoul" > /etc/timezone
}
set_default_user_account() {
echo "###########################################################"
echo "#"
echo "# 사용자 디렉토리 변경 및 /home/${NEW_USER} 삭제"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
if [[ ${NEW_USER_HOME} != "/home/${NEW_USER}" ]]
then
mkdir -p ${NEW_USER_HOME}
usermod -d ${NEW_USER_HOME} ${NEW_USER}
cp -f /home/${NEW_USER}/.bash_logout ${NEW_USER_HOME}
cp -f /home/${NEW_USER}/.bashrc ${NEW_USER_HOME}
cp -f /home/${NEW_USER}/.profile ${NEW_USER_HOME}
chown -R ${NEW_USER}:${NEW_GROUP} ${NEW_USER_HOME}
rm -rf /home/${NEW_USER}
fi
}
copy_skel_profile() {
echo "###########################################################"
echo "#"
echo "# root 프로파일 복사 (일부 없는 경우만 해당)"
echo "#"
echo "###########################################################"
cp -fv /etc/skel/.profile /root/
}
set_network() {
if [ ${SET_NETWORK_CONFIG} = 1 ]
then
echo "###########################################################"
echo "#"
echo "# 네트워크 셋팅 (IP주소 수정 후 실행)"
echo "#"
echo "# Wifi와 Ethernet은 한가지만 사용가능하며,"
echo "# 만일 Wifi를 사용하기 위해서는 \"auto eth0\"를 삭제한다."
echo "#"
echo "###########################################################"
echo "# Ethernet" > /etc/network/interfaces.d/eth0
echo "auto eth0" >> /etc/network/interfaces.d/eth0
echo "allow-hotplug eth0" >> /etc/network/interfaces.d/eth0
echo "no-auto-down eth0" >> /etc/network/interfaces.d/eth0
echo "# Wifi를 주 네트워크로 사용할 경우 eth0의 inet을 manual로 설정한다." >> /etc/network/interfaces.d/eth0
echo "iface eth0 inet static" >> /etc/network/interfaces.d/eth0
echo "#iface eth0 inet dhcp" >> /etc/network/interfaces.d/eth0
echo "address ${ETH0_IP}" >> /etc/network/interfaces.d/eth0
echo "netmask ${ETH0_NM}" >> /etc/network/interfaces.d/eth0
echo "gateway ${GATEWAY}" >> /etc/network/interfaces.d/eth0
echo "dns-nameservers ${DNS_SERVER1} ${DNS_SERVER2}" >> /etc/network/interfaces.d/eth0
echo "# WiFi" > /etc/network/interfaces.d/wlan0
echo "auto wlan0" >> /etc/network/interfaces.d/wlan0
echo "allow-hotplug wlan0" >> /etc/network/interfaces.d/wlan0
if [ ${WIFI_ENABLE} = 1 ]
then
echo "iface wlan0 inet dhcp" >> /etc/network/interfaces.d/wlan0
echo "#iface wlan0 inet manual" >> /etc/network/interfaces.d/wlan0
systemctl enable wpa_supplicant.service
else
echo "#iface wlan0 inet dhcp" >> /etc/network/interfaces.d/wlan0
echo "iface wlan0 inet manual" >> /etc/network/interfaces.d/wlan0
systemctl disable wpa_supplicant.service
fi
echo "wireless-mode Managed" >> /etc/network/interfaces.d/wlan0
echo "wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf" >> /etc/network/interfaces.d/wlan0
echo "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev" > /etc/wpa_supplicant/wpa_supplicant.conf
echo "update_config=1" >> /etc/wpa_supplicant/wpa_supplicant.conf
echo "" >> /etc/wpa_supplicant/wpa_supplicant.conf
echo "network={" >> /etc/wpa_supplicant/wpa_supplicant.conf
echo " ssid=\"${WIFI_SSID}\"" >> /etc/wpa_supplicant/wpa_supplicant.conf
echo " psk=\"${WIFI_PW}\"" >> /etc/wpa_supplicant/wpa_supplicant.conf
echo " key_mgmt=WPA-PSK" >> /etc/wpa_supplicant/wpa_supplicant.conf
echo " priority=99" >> /etc/wpa_supplicant/wpa_supplicant.conf
echo "}" >> /etc/wpa_supplicant/wpa_supplicant.conf
sed -i "s/iface eth0 inet dhcp/#iface eth0 inet dhcp/g" /etc/network/interfaces
chmod 644 /etc/network/interfaces.d/eth0
chmod 644 /etc/network/interfaces.d/lo
chmod 644 /etc/network/interfaces.d/wlan0
chmod 644 /etc/wpa_supplicant/wpa_supplicant.conf
#nmcli radio wifi off
echo "" >> /etc/sysctl.conf
echo "###########################################################" >> /etc/sysctl.conf
echo "#" >> /etc/sysctl.conf
echo "# Disable IPv6" >> /etc/sysctl.conf
echo "#" >> /etc/sysctl.conf
echo "###########################################################" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6=1" >> /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6=1" >> /etc/sysctl.conf
fi
}
set_dns() {
echo "###########################################################"
echo "#"
echo "# 네트워크 셋팅 (DNS)"
echo "#"
echo "###########################################################"
chmod 666 /etc/resolv.conf
echo "nameserver ${DNS_SERVER1}" >> /etc/resolv.conf
echo "nameserver ${DNS_SERVER2}" >> /etc/resolv.conf
chmod 644 /etc/resolv.conf
}
update_os() {
echo "###########################################################"
echo "#"
echo "# 전체 패키지 업데이트"
echo "#"
echo "###########################################################"
${APTCMD} update -y
${APTCMD} upgrade -y
${APTCMD} dist-upgrade -y
deb_clean
}
install_additional_repo() {
echo "###########################################################"
echo "#"
echo "# apt repository 관리자 설치"
echo "#"
echo "###########################################################"
${APTCMD} -y install software-properties-common
${APTCMD} -y install python-software-properties
}
install_apt_get_pkgs() {
echo "###########################################################"
echo "#"
echo "# 필요한 패키지 설치"
echo "# (설치가 안될 수 있으니 리부팅 후 확인 요망)"
echo "#"
echo "###########################################################"
sync
${APTCMD} -y install at
${APTCMD} -y install python
${APTCMD} -y install lrzsz
${APTCMD} -y install vim
${APTCMD} -y install telnet
${APTCMD} -y install ntp
${APTCMD} -y install ntpdate
${APTCMD} -y install lshw
${APTCMD} -y install autofs
${APTCMD} -y install screen
${APTCMD} -y install wireless-tools wpasupplicant hostapd
${APTCMD} -y install expect
${APTCMD} -y install gzip bzip2 tar unrar arj p7zip-full minicom mc ftp lsof
${APTCMD} -y install zip unzip zlib1g-dev
${APTCMD} -y install iptables ipset bridge-utils isc-dhcp-server iperf
${APTCMD} -y install conntrack
${APTCMD} -y install ntfs-3g
${APTCMD} -y install exfat-fuse exfat-utils
${APTCMD} -y install lftp
${APTCMD} -y install git
${APTCMD} -y install subversion subversion-tools
${APTCMD} -y install ffmpeg
${APTCMD} -y install cifs-utils
${APTCMD} -y install tcpdump netcat
${APTCMD} -y install mediainfo sox
${APTCMD} -y install livemedia-utils
${APTCMD} -y install nfs-common
${APTCMD} -y install whois
${APTCMD} -y install net-tools
${APTCMD} -y install wakeonlan
${APTCMD} -y install wget
${APTCMD} -y install cmake
${APTCMD} -y install apt-transport-https ca-certificates curl gnupg lsb-release
${APTCMD} -y install ${NEW_USER}-config
${APTCMD} -y install rpimonitor
${APTCMD} -y install hdparm
${APTCMD} -y install lm_sensors hddtemp
${APTCMD} -y install build-essential
${APTCMD} -y install libtool
${APTCMD} -y install pkg-config
sensors-detect --auto
# orange pi zero2는 xrdp,xorgxrdp를 컴파일하여 수동설치
if [[ ${BOARD_NAME_SHORT} = "opizero2" ]]
then
${APTCMD} -y install xserver-xorg-dev
${APTCMD} -y install libpam0g-dev
${APTCMD} -y install libjpeg-dev
${APTCMD} -y install libfuse-dev
${APTCMD} -y install libmp3lame-dev
${APTCMD} -y install libxfixes-dev
${APTCMD} -y install libxrandr-dev
fi
# python3
${APTCMD} -y upgrade python3
${APTCMD} -y upgrade python3-pip
pip install --upgrade pip
${APTCMD} -y upgrade python3-dev
# yt_dlp
wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp
chmod a+rx /usr/local/bin/yt-dlp
/usr/local/bin/yt-dlp -U
}
install_rclone() {
echo "###########################################################"
echo "#"
echo "# rclone 설치 (https://rclone.org/downloads/)"
echo "#"
echo "###########################################################"
mkdir -p /tmp/rclone
wget --no-check-certificate "https://downloads.rclone.org/rclone-current-linux-arm.zip" -O /tmp/rclone/rclone.zip
unzip /tmp/rclone/rclone.zip -d /tmp/rclone
cp -fv /tmp/rclone/rclone-*/rclone /usr/bin
chmod 755 /usr/bin/rclone
rm -rf /tmp/rclone
}
install_docker() {
echo "###########################################################"
echo "#"
echo "# docker 설치"
echo "#"
echo "###########################################################"
if [ ${USE_DOCKER} = 1 ]
then
${APTCMD} -y install docker
${APTCMD} -y install docker.io
${APTCMD} -y install docker-compose
#rm -f /usr/share/keyrings/docker-archive-keyring.gpg /etc/apt/sources.list.d/docker.list*
#curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
#echo "deb [arch=${DOCKER_ARCH} signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
#add-apt-repository "deb [arch=${DOCKER_ARCH}] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
#${APTCMD} -y update
#${APTCMD} -y install docker-ce docker-ce-cli containerd.io
# docker-compose
#pip3 install docker-compose
fi
}
install_nfs_server() {
echo "###########################################################"
echo "#"
echo "# NFS Server 설정"
echo "#"
echo "###########################################################"
if [ ${USE_NFS_SERVER} = 1 ]
then
${APTCMD} -y install nfs-kernel-server
${APTCMD} -y install rpcbind
sync
sed -i "s/STATDOPTS=/STATDOPTS=\"--port 4000\"/g" /etc/default/nfs-common
sed -i "s/RPCMOUNTDOPTS=\"--manage-gids\"/RPCMOUNTDOPTS=\"--manage-gids -p 4002\"/g" /etc/default/nfs-kernel-server
echo "${STORAGE_MOUNT_DIR} *(rw,sync,no_subtree_check,all_squash,anonuid=1000,anongid=1000)" >> /etc/exports
echo "" >> /etc/sysctl.conf
echo "###########################################################" >> /etc/sysctl.conf
echo "#" >> /etc/sysctl.conf
echo "# NFS nlockmgr port" >> /etc/sysctl.conf
echo "#" >> /etc/sysctl.conf
echo "###########################################################" >> /etc/sysctl.conf
echo "fs.nfs.nlm_tcpport=4001" >> /etc/sysctl.conf
echo "fs.nfs.nlm_udpport=4001" >> /etc/sysctl.conf
exportfs -a
systemctl daemon-reload
systemctl restart nfs-kernel-server
systemctl enable nfs-kernel-server
systemctl enable rpcbind.service
rpcinfo -p
else
systemctl daemon-reload
systemctl stop nfs-kernel-server
systemctl disable nfs-kernel-server
systemctl disable rpcbind.service
fi
}
set_vim() {
echo "###########################################################"
echo "#"
echo "# vim 설정"
echo "#"
echo "###########################################################"
echo "set encoding=utf-8" >> /etc/vim/vimrc
echo "set fencs=utf-8,euc-kr" >> /etc/vim/vimrc
echo "set fileencodings=utf-8,euc-kr" >> /etc/vim/vimrc
echo "set indentexpr=" >> /etc/vim/vimrc
echo "set noautoindent" >> /etc/vim/vimrc
echo "set nocindent" >> /etc/vim/vimrc
echo "set nosmartindent" >> /etc/vim/vimrc
echo "set paste" >> /etc/vim/vimrc
}
install_apache2() {
echo "###########################################################"
echo "#"
echo "# apache2 패키지 설치"
echo "#"
echo "###########################################################"
if [ ${USE_APACHE2} = 1 ]
then
${APTCMD} -y install apache2
${APTCMD} -y install apache2-utils
${APTCMD} -y install libapache2-mod-fcgid
${APTCMD} -y install libapache2-mod-svn
${APTCMD} -y install libcgi-session-perl
rm -rf ${WWW_DIR}/*
chown -R www-data:www-data ${WWW_DIR}
systemctl daemon-reload
a2enmod rewrite
a2enmod dav
a2enmod dav_fs
a2enmod dav_svn
a2enmod auth_digest
a2enmod ssl
a2enmod proxy_wstunnel
a2enmod proxy_http
a2enmod headers
a2enmod env
a2enmod alias
a2enmod fcgid
cp -fv /etc/apache2/apache2.conf /etc/apache2/apache2.conf.${TIMESTAMP}
cp -fv /etc/apache2/ports.conf /etc/apache2/ports.conf.${TIMESTAMP}
cp -fv /etc/apache2/envvars /etc/apache2/envvars.${TIMESTAMP}
fi
}
install_mariadb() {
echo "###########################################################"
echo "#"
echo "# mariaDB 패키지 설치"
echo "#"
echo "###########################################################"
if [ ${USE_MARIADB} = 1 ]
then
${APTCMD} -y install mariadb-server
sed -i "s/127.0.0.1/0.0.0.0/g" /etc/mysql/my.cnf
sed -i "s/127.0.0.1/0.0.0.0/g" /etc/mysql/mariadb.conf.d/50-server.cnf
systemctl stop mysql.service
rm -rf /var/lib/mysql/*
/usr/bin/mysql_install_db
systemctl daemon-reload
systemctl enable mysql.service
fi
}
install_php() {
echo "###########################################################"
echo "#"
echo "# php 패키지 설치"
echo "#"
echo "###########################################################"
if [ ${USE_PHP} = 1 ]
then
${APTCMD} -y install php
${APTCMD} -y install libapache2-mod-php
${APTCMD} -y install php-cli
${APTCMD} -y install php-curl
${APTCMD} -y install php-gd
${APTCMD} -y install php-gmp
${APTCMD} -y install php-imagick
${APTCMD} -y install php-intl
${APTCMD} -y install php-json
${APTCMD} -y install php-mbstring
${APTCMD} -y install php-mysql
${APTCMD} -y install php-pear
${APTCMD} -y install php-xml
${APTCMD} -y install php-xmlrpc
${APTCMD} -y install php-zip
PHP_VER=$(php --version | head -n 1 | cut -d " " -f 2 | cut -c 1-3)
cp -fv /etc/php/${PHP_VER}/apache2/php.ini /etc/php/${PHP_VER}/apache2/php.ini.${TIMESTAMP}
fi
}
install_letsencrypt() {
echo "###########################################################"
echo "#"
echo "# Let's encrypt 설치"
echo "#"
echo "###########################################################"
if [ ${USE_LETSENCRYPT} = 1 ]
then
${APTCMD} -y install letsencrypt
${APTCMD} -y install python3-certbot-apache
fi
}
install_vsftpd() {
echo "###########################################################"
echo "#"
echo "# vsftpd 패키지 설치"
echo "#"
echo "###########################################################"
if [ ${USE_VSFTPD} = 1 ]
then
${APTCMD} -y install vsftpd
cp -fv /etc/vsftpd.conf /etc/vsftpd.conf.${TIMESTAMP}
fi
}
install_samba() {
echo "###########################################################"
echo "#"
echo "# samba 패키지 설치"
echo "#"
echo "###########################################################"
if [ ${USE_SAMBA} = 1 ]
then
echo "samba-common samba-common/workgroup string WORKGROUP" | sudo debconf-set-selections
echo "samba-common samba-common/dhcp boolean true" | sudo debconf-set-selections
echo "samba-common samba-common/do_debconf boolean true" | sudo debconf-set-selections
${APTCMD} -y install samba
${APTCMD} -y install samba-common-bin
${APTCMD} -y install cifs-utils
${APTCMD} -y install smbclient
cp -fv /etc/samba/smb.conf /etc/samba/smb.conf.${TIMESTAMP}
fi
}
install_plexmediaserver() {
echo "###########################################################"
echo "#"
echo "# plex media server 설치"
echo "#"
echo "###########################################################"
if [ ${USE_PLEXMEDIASERVER} = 1 ]
then
${APTCMD} -y install apt-transport-https
curl https://downloads.plex.tv/plex-keys/PlexSign.key | apt-key add -
echo deb https://downloads.plex.tv/repo/deb public main | tee /etc/apt/sources.list.d/plexmediaserver.list
${APTCMD} update
${APTCMD} -y install plexmediaserver
sed -i "s/User=plex/User=${NEW_USER}/g" /lib/systemd/system/plexmediaserver.service
sed -i "s/Group=plex/Group=${NEW_USER}/g" /lib/systemd/system/plexmediaserver.service
chown -R ${NEW_USER}:${NEW_GROUP} /var/lib/plexmediaserver
systemctl daemon-reload
systemctl stop plexmediaserver
##########################################################################
#
# 아래 주소로 접속 테스트
# http://192.168.1.20:32400/web/
#
##########################################################################
##########################################################################
#
# 캐쉬 클리어
#
##########################################################################
rm -rf "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Cache"
rm -rf "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs"
rm -rf "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Media"
mkdir -p "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Cache"
mkdir -p "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs"
mkdir -p "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Media"
chown -R ${NEW_USER}:${NEW_GROUP} /var/lib/plexmediaserver
systemctl enable plexmediaserver
fi
}
install_xwindow() {
echo "###########################################################"
echo "#"
echo "# X-Window & LXDE 설치"
echo "#"
echo "# 설치 후 im-config 를 실행하여 한글입력 환경을 설정한다."
echo "#"
echo "###########################################################"
if [ ${USE_XWINDOW} = 1 ]
then
${APTCMD} -y install xorg
${APTCMD} -y install xfonts-base
${APTCMD} -y install xserver-xorg-video-dummy
${APTCMD} -y install policykit-1
if [ ${DESKTOP_ENVIRONMENT} = "LXDE" ]
then
${APTCMD} -y install lxde
${APTCMD} -y install lxterminal
${APTCMD} -y install lxde-icon-theme
${APTCMD} -y install lxmusic
fi
if [ ${DESKTOP_ENVIRONMENT} = "XFCE" ]
then
${APTCMD} -y install xfce4
${APTCMD} -y install xfce4-goodies
fi
if [ ${DESKTOP_ENVIRONMENT} = "GNOME" ]
then
${APTCMD} -y install gnome-session
${APTCMD} -y install gdm3
${APTCMD} -y install gnome-panel
${APTCMD} -y install metacity
${APTCMD} -y install light-themes
fi
if [[ ${BOARD_NAME_SHORT} = "opizero2" ]]
then
echo "Section \"Device\"" > /etc/X11/xorg.conf.d/99-fbdev.conf
echo " Identifier \"myfb\"" >> /etc/X11/xorg.conf.d/99-fbdev.conf
echo " Driver \"fbdev\"" >> /etc/X11/xorg.conf.d/99-fbdev.conf
echo " Option \"fbdev\" \"/dev/fb1\"" >> /etc/X11/xorg.conf.d/99-fbdev.conf
echo "EndSection" >> /etc/X11/xorg.conf.d/99-fbdev.conf
fi
${APTCMD} -y install wpagui
${APTCMD} -y install language-pack-ko
${APTCMD} -y install korean*
${APTCMD} -y install ubuntu-wallpapers
${APTCMD} -y install xfonts-cyrillic
${APTCMD} -y install xfonts-100dpi
${APTCMD} -y install xfonts-75dpi
${APTCMD} -y install xfonts-tipa
${APTCMD} -y install fonts-unfonts-core fonts-unfonts-extra
${APTCMD} -y install xfonts-baekmuk fonts-baekmuk
${APTCMD} -y install fonts-nanum fonts-nanum-coding fonts-nanum-extra
${APTCMD} -y install fonts-noto-color-emoji
${APTCMD} -y install atril
${APTCMD} -y install filezilla
#${APTCMD} -y install chromium-browser
${APTCMD} -y install galculator
${APTCMD} -y install gedit
${APTCMD} -y install gpicview
${APTCMD} -y install putty
${APTCMD} -y install remmina
${APTCMD} -y install remmina-plugin-rdp
${APTCMD} -y install remmina-plugin-secret
${APTCMD} -y install vlc
${APTCMD} -y install thunderbird
${APTCMD} -y install thunderbird-locale-ko
${APTCMD} -y install libreoffice
${APTCMD} -y install libreoffice-l10n-ko
${APTCMD} -y install libreoffice-help-ko
update-icon-caches /usr/share/icons/*
if [ ${DESKTOP_ENVIRONMENT} = "LXDE" ]
then
echo "lxsession -s LXDE -e LXDE" > /root/.xsession
echo "lxsession -s LXDE -e LXDE" > ${NEW_USER_HOME}/.xsession
fi
if [ ${DESKTOP_ENVIRONMENT} = "XFCE" ]
then
echo "xfce4-session" > /root/.xsession
echo "xfce4-session" > ${NEW_USER_HOME}/.xsession
fi
if [ ${DESKTOP_ENVIRONMENT} = "GNOME" ]
then
echo "gnome-session" > /root/.xsession
echo "gnome-session" > ${NEW_USER_HOME}/.xsession
fi
echo "Section \"ServerFlags\"" > /etc/X11/xorg.conf.d/xorg.conf
echo " Option \"BlankTime\" \"0\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo " Option \"StandbyTime\" \"0\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo " Option \"SuspendTime\" \"0\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo " Option \"OffTime\" \"0\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo "EndSection" >> /etc/X11/xorg.conf.d/xorg.conf
echo "Section \"Device\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo " Identifier \"Configured Video Device\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo " Driver \"dummy\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo "EndSection" >> /etc/X11/xorg.conf.d/xorg.conf
echo "Section \"Monitor\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo " Identifier \"Configured Monitor\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo " HorizSync 31.5-48.5" >> /etc/X11/xorg.conf.d/xorg.conf
echo " VertRefresh 50-70" >> /etc/X11/xorg.conf.d/xorg.conf
echo " Option \"DPMS\" \"false\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo "EndSection" >> /etc/X11/xorg.conf.d/xorg.conf
echo "Section \"Screen\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo " Identifier \"Default Screen\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo " Monitor \"Configured Monitor\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo " Device \"Configured Video Device\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo " DefaultDepth 24" >> /etc/X11/xorg.conf.d/xorg.conf
echo " SubSection \"Display\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo " Depth 24" >> /etc/X11/xorg.conf.d/xorg.conf
echo " Modes \"1024x800\"" >> /etc/X11/xorg.conf.d/xorg.conf
echo " EndSubSection" >> /etc/X11/xorg.conf.d/xorg.conf
echo "EndSection" >> /etc/X11/xorg.conf.d/xorg.conf
fi
}
install_xrdp() {
echo "###########################################################"
echo "#"
echo "# xrdp 설치"
echo "#"
echo "###########################################################"
if [ ${USE_XRDP} = 1 ]
then
${APTCMD} -y install xrdp
${APTCMD} -y install xorgxrdp
cp -f /etc/X11/xrdp/xorg.conf /etc/X11/xrdp/xorg.conf.${TIMESTAMP}
cp -f /etc/xrdp/pulse/default.pa /etc/xrdp/pulse/default.pa.${TIMESTAMP}
cp -f /etc/xrdp/sesman.ini /etc/xrdp/sesman.ini.${TIMESTAMP}
cp -f /etc/xrdp/startwm.sh /etc/xrdp/startwm.sh.${TIMESTAMP}
cp -f /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.${TIMESTAMP}
cp -f /etc/xrdp/xrdp_keyboard.ini /etc/xrdp/xrdp_keyboard.ini.${TIMESTAMP}
sed -i "s/^test -x/#test -x/g" /etc/xrdp/startwm.sh
sed -i "s/^exec \/bin\/sh/#exec \/bin\/sh/g" /etc/xrdp/startwm.sh
if [ ${DESKTOP_ENVIRONMENT} = "LXDE" ]
then
echo "lxsession -s LXDE -e LXDE" >> /etc/xrdp/startwm.sh
fi
if [ ${DESKTOP_ENVIRONMENT} = "XFCE" ]
then
echo "xfce4-session" >> /etc/xrdp/startwm.sh
fi
if [ ${DESKTOP_ENVIRONMENT} = "GNOME" ]
then
echo "gnome-session" >> /etc/xrdp/startwm.sh
fi
systemctl daemon-reload
systemctl enable xrdp.service
rm -f /var/log/xrdp*
touch /var/log/xrdp.log
chown xrdp:adm /var/log/xrdp.log
chmod 640 /var/log/xrdp.log
fi
}
install_hangul_ime() {
echo "###########################################################"
echo "#"
echo "# 한글 입력기 설치"
echo "#"
echo "###########################################################"
# 한글 입력기 fcitx
if [ ${HANGUL_IME} = "fcitx" ]
then
${APTCMD} -y install fcitx-bin
${APTCMD} -y install fcitx-frontend-gtk2
${APTCMD} -y install fcitx-frontend-gtk3
${APTCMD} -y install fcitx-frontend-qt5
${APTCMD} -y install fcitx-hangul
${APTCMD} -y install fcitx-ui-classic
${APTCMD} -y install fonts-noto-cjk
${APTCMD} -y install fonts-noto-cjk-extra
${APTCMD} -y install hunspell-ko
${APTCMD} -y install language-pack-gnome-ko
fi
# 한글 입력기 ibus
if [ ${HANGUL_IME} = "ibus" ]
then
${APTCMD} -y install ibus
${APTCMD} -y install ibus-hangul
echo "export GTK_IM_MODULE=ibus" >> ${NEW_USER_HOME}/.bashrc
echo "export QT_IM_MODULE=ibus" >> ${NEW_USER_HOME}/.bashrc
echo "export XMODIFIERS=@im=ibus" >> ${NEW_USER_HOME}/.bashrc
echo "export GTK_IM_MODULE=ibus" >> /root/.bashrc
echo "export QT_IM_MODULE=ibus" >> /root/.bashrc
echo "export XMODIFIERS=@im=ibus" >> /root/.bashrc
echo "@ibus-daemon -d" >> /etc/xdg/lxsession/LXDE/autostart
fi
# 한글 입력기 uim-byeoru
if [ ${HANGUL_IME} = "uim" ]
then
${APTCMD} -y --install-recommends install uim uim-byeoru
${APTCMD} -y install lxhotkey-plugin-openbox
${APTCMD} -y install im-config
fi
}
install_vncserver() {
echo "###########################################################"
echo "#"
echo "# vncserver설치"
echo "#"
echo "###########################################################"
if [ ${USE_VNC_SERVER} = 1 ]
then
${APTCMD} -y install tigervnc-common
${APTCMD} -y install tightvncserver
mkdir -p ${NEW_USER_HOME}/.vnc
echo '#!/bin/sh' > ${NEW_USER_HOME}/.vnc/xstartup
echo "" >> ${NEW_USER_HOME}/.vnc/xstartup
echo "# Uncomment the following two lines for normal desktop:" >> ${NEW_USER_HOME}/.vnc/xstartup
echo "# unset SESSION_MANAGER" >> ${NEW_USER_HOME}/.vnc/xstartup
echo "# exec /etc/X11/xinit/xinitrc" >> ${NEW_USER_HOME}/.vnc/xstartup
echo "" >> ${NEW_USER_HOME}/.vnc/xstartup
echo "[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup" >> ${NEW_USER_HOME}/.vnc/xstartup
echo "[ -r \$HOME/.Xresources ] && xrdb \$HOME/.Xresources" >> ${NEW_USER_HOME}/.vnc/xstartup
echo "xsetroot -solid grey -cursor_name left_ptr" >> ${NEW_USER_HOME}/.vnc/xstartup
echo "xrdb \$HOME/.Xresources" >> ${NEW_USER_HOME}/.vnc/xstartup
if [ ${DESKTOP_ENVIRONMENT} = "LXDE" ]
then
echo "startlxde &" >> ${NEW_USER_HOME}/.vnc/xstartup
fi
if [ ${DESKTOP_ENVIRONMENT} = "XFCE" ]
then
echo "startxfce4 &" >> ${NEW_USER_HOME}/.vnc/xstartup
fi
if [ ${DESKTOP_ENVIRONMENT} = "GNOME" ]
then
echo "gnome-session --builtin --session=gnome-flashback-metacity --disable-acceleration-check --debug &" >> ${NEW_USER_HOME}/.vnc/xstartup
echo "nautilus &" >> ${NEW_USER_HOME}/.vnc/xstartup
echo "gnome-terminal &" >> ${NEW_USER_HOME}/.vnc/xstartup
fi
chmod 755 ${NEW_USER_HOME}/.vnc/xstartup
echo "[Unit]" > /lib/systemd/system/vncserver.service
echo "Description=Tight VNC Server" >> /lib/systemd/system/vncserver.service
echo "" >> /lib/systemd/system/vncserver.service
echo "[Service]" >> /lib/systemd/system/vncserver.service
echo "Type=forking" >> /lib/systemd/system/vncserver.service
echo "User=${NEW_USER}" >> /lib/systemd/system/vncserver.service
echo "ExecStart=/usr/bin/vncserver :1 -deferglyphs all -geometry 1024x768" >> /lib/systemd/system/vncserver.service
echo "ExecStop=/usr/bin/vncserver -kill :1" >> /lib/systemd/system/vncserver.service
echo "" >> /lib/systemd/system/vncserver.service
echo "[Install]" >> /lib/systemd/system/vncserver.service
echo "WantedBy=multi-user.target" >> /lib/systemd/system/vncserver.service
chown -R ${NEW_USER}:${NEW_GROUP} ${NEW_USER_HOME}
chown -R ${NEW_USER}:${NEW_GROUP} ${NEW_USER_HOME}/.vnc
systemctl daemon-reload
systemctl enable vncserver.service
fi
}
install_transmission_daemon() {
echo "###########################################################"
echo "#"
echo "# transmission-daemon 설치"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
if [ ${USE_TRANSMISSION} = 1 ]
then
${APTCMD} -y install transmission-daemon
cp -fv /etc/transmission-daemon/settings.json /etc/transmission-daemon/settings.json.${TIMESTAMP}
sed -i "s/\"rpc-username\": \"transmission\",/\"rpc-username\": \"${NEW_USER}\",/g" /etc/transmission-daemon/settings.json
sed -i "s/\"incomplete-dir\": \"\/var\/lib\/transmission-daemon\/Downloads\",/\"incomplete-dir\": \"\\${STORAGE_MOUNT_DIR}\/transmission-daemon\/incomplete\",/g" /etc/transmission-daemon/settings.json
sed -i "s/\"download-dir\": \"\/var\/lib\/transmission-daemon\/downloads\",/\"download-dir\": \"\\${STORAGE_MOUNT_DIR}\/transmission-daemon\/downloads\",/g" /etc/transmission-daemon/settings.json
sed -i "s/\"rpc-whitelist-enabled\": true,/\"rpc-whitelist-enabled\": false,/g" /etc/transmission-daemon/settings.json
invoke-rc.d transmission-daemon reload
sed -i "s/USER=debian-transmission/USER=${NEW_USER}/g" /etc/init.d/transmission-daemon
sed -i "s/User=debian-transmission/User=${NEW_USER}/g" /lib/systemd/system/transmission-daemon.service
mkdir -p ${NEW_USER_HOME}/.config/transmission-daemon
cp -fv /etc/transmission-daemon/settings.json ${NEW_USER_HOME}/.config/transmission-daemon/
invoke-rc.d transmission-daemon reload
mkdir -p ${STORAGE_MOUNT_DIR}/transmission-daemon/incomplete
mkdir -p ${STORAGE_MOUNT_DIR}/transmission-daemon/downloads
chown -R ${NEW_USER}:${NEW_GROUP} /etc/transmission-daemon
chown -R ${NEW_USER}:${NEW_GROUP} /var/lib/transmission-daemon
chown -R ${NEW_USER}:${NEW_GROUP} ${STORAGE_MOUNT_DIR}/transmission-daemon
chmod 777 ${STORAGE_MOUNT_DIR}/transmission-daemon/downloads
systemctl daemon-reload
systemctl enable transmission-daemon.service
fi
}
install_audio() {
echo "###########################################################"
echo "#"
echo "# Install Audio"
echo "# TEST)"
echo "# aplay -l"
echo "# speaker-test"
echo "# mpg123 test.mp3"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
if [ ${USE_BT_AUDIO} = 1 ]
then
# 블루투스 패키지 설치
${APTCMD} -y install bluetooth
${APTCMD} -y install bluez
${APTCMD} -y install bluez-tools
${APTCMD} -y install rfkill
${APTCMD} -y install blueman
# 오디오 패키지 설치
${APTCMD} -y install python-gobject python-gobject-2
${APTCMD} -y install alsa-base
${APTCMD} -y install alsa-utils
${APTCMD} -y install autoconf
${APTCMD} -y install libasound2
${APTCMD} -y install libasound2-dev
${APTCMD} -y install libbluetooth-dev
${APTCMD} -y install libdbus-1-dev
${APTCMD} -y install libglib2.0-dev
${APTCMD} -y install libsbc-dev
${APTCMD} -y install libtool
${APTCMD} -y install linux-sound-base
${APTCMD} -y install pavucontrol
${APTCMD} -y install pulseaudio
${APTCMD} -y install mpg123
${APTCMD} -y install pulseaudio-module-bluetooth
echo 'pcm.!default {' > /etc/asound.conf
echo ' type hw' >> /etc/asound.conf
echo ' card 0' >> /etc/asound.conf
echo ' device 0' >> /etc/asound.conf
echo '}' >> /etc/asound.conf
echo 'ctl.!default {' >> /etc/asound.conf
echo ' type hw' >> /etc/asound.conf
echo ' card 0' >> /etc/asound.conf
echo '}' >> /etc/asound.conf
echo "###########################################################"
echo "#"
echo "# Install Sound-Build bluealsa"
echo "#"
echo "###########################################################"
wget --no-check-certificate -P /tmp "https://github.com/Arkq/bluez-alsa/archive/master.zip"
cd /tmp
unzip master.zip
cd bluez-alsa-master/
autoreconf --install
mkdir build && cd build
../configure
make -j4
make install
rm -rf /tmp/master.zip /tmp/bluez-alsa-master
echo '[Unit]' > /lib/systemd/system/bluealsa.service
echo 'Description=Bluealsa daemon' >> /lib/systemd/system/bluealsa.service
echo 'Documentation=https://github.com/Arkq/bluez-alsa/' >> /lib/systemd/system/bluealsa.service
echo 'After=dbus-org.bluez.service' >> /lib/systemd/system/bluealsa.service
echo 'Requires=dbus-org.bluez.service' >> /lib/systemd/system/bluealsa.service
echo '' >> /lib/systemd/system/bluealsa.service
echo '[Service]' >> /lib/systemd/system/bluealsa.service
echo 'Type=dbus' >> /lib/systemd/system/bluealsa.service
echo 'BusName=org.bluealsa' >> /lib/systemd/system/bluealsa.service
echo 'EnvironmentFile=-/etc/default/bluealsa' >> /lib/systemd/system/bluealsa.service
echo 'ExecStart=/usr/bin/bluealsa $OPTIONS' >> /lib/systemd/system/bluealsa.service
echo 'Restart=on-failure' >> /lib/systemd/system/bluealsa.service
echo 'ProtectSystem=strict' >> /lib/systemd/system/bluealsa.service
echo 'ProtectHome=true' >> /lib/systemd/system/bluealsa.service
echo 'PrivateTmp=true' >> /lib/systemd/system/bluealsa.service
echo 'PrivateDevices=true' >> /lib/systemd/system/bluealsa.service
echo 'RemoveIPC=true' >> /lib/systemd/system/bluealsa.service
echo 'RestrictAddressFamilies=AF_UNIX AF_BLUETOOTH' >> /lib/systemd/system/bluealsa.service
echo '; Also non-privileged can user be used' >> /lib/systemd/system/bluealsa.service
echo '; this example assumes a user and group called 'bluealsa' exist' >> /lib/systemd/system/bluealsa.service
echo ';User=bluealsa' >> /lib/systemd/system/bluealsa.service
echo ';Group=bluealsa' >> /lib/systemd/system/bluealsa.service
echo ';NoNewPrivileges=true' >> /lib/systemd/system/bluealsa.service
echo '' >> /lib/systemd/system/bluealsa.service
echo '[Install]' >> /lib/systemd/system/bluealsa.service
echo 'WantedBy=bluetooth.target' >> /lib/systemd/system/bluealsa.service
systemctl daemon-reload
systemctl enable bluealsa.service
systemctl start bluealsa.service
echo '#!/bin/bash' > ~/bluetooth_autoconnect.sh
echo 'MACADDR1="1c:52:16:6d:0a:7b"' >> ~/bluetooth_autoconnect.sh
echo 'bluetoothctl << EOF' >> ~/bluetooth_autoconnect.sh
echo 'connect ${MACADDR1}' >> ~/bluetooth_autoconnect.sh
echo 'EOF' >> ~/bluetooth_autoconnect.sh
chmod 755 ~/bluetooth_autoconnect.sh
# 오디오 디바이스 활성화
armbian-config main=System selection=Hardware selection=analog-codec
fi
#bluetoothctl
#[bluetooth]# scan on
#...
#[bluetooth]# scan off
#[bluetooth]# pair 1c:52:16:6d:0a:7b
#[bluetooth]# connect 1c:52:16:6d:0a:7b
#[bluetooth]# quit
#aplay -D bluealsa:DEV=1c:52:16:6d:0a:7b,PROFILE=a2dp test.wav
}
get_pydiouser_pw() {
echo "###########################################################"
echo "#"
echo "# pydio DB 비밀번호 설정"
echo "#"
echo "###########################################################"
if [ ${USE_PYDIO} = 1 ]
then
echo -n ">> Input 'pydiouser' DB Password: "
read PYDIO_DB_PW
echo "'pydiouser' DB Password: ${PYDIO_DB_PW}"
echo ""
fi
}
setup_pydio_db() {
echo "###########################################################"
echo "#"
echo "# pydio DB 설정"
echo "#"
echo "###########################################################"
if [ ${USE_PYDIO} = 1 ]
then
cd ${CURRENT_DIR}
systemctl restart mysql
echo "DROP DATABASE IF EXISTS pydio;" > _pydio_tmp_
echo "DROP USER IF EXISTS 'pydiouser'@'localhost';" >> _pydio_tmp_
echo "DROP USER IF EXISTS 'pydiouser'@'%';" >> _pydio_tmp_
echo "CREATE DATABASE pydio CHARACTER SET utf8 COLLATE utf8_bin;" >> _pydio_tmp_
echo "GRANT ALL PRIVILEGES ON pydio.* TO 'pydiouser'@'localhost' IDENTIFIED BY '${PYDIO_DB_PW}' WITH GRANT OPTION;" >> _pydio_tmp_
echo "GRANT ALL PRIVILEGES ON pydio.* TO 'pydiouser'@'%' IDENTIFIED BY '${PYDIO_DB_PW}' WITH GRANT OPTION;" >> _pydio_tmp_
echo "FLUSH PRIVILEGES;" >> _pydio_tmp_
mysql -u root < _pydio_tmp_
rm -f _pydio_tmp_
fi
}
install_pydio() {
echo "###########################################################"
echo "#"
echo "# pydio 설치"
echo "#"
echo "###########################################################"
if [ ${USE_PYDIO} = 1 ]
then
cd ${CURRENT_DIR}
wget --no-check-certificate "https://download.pydio.com/pub/core/archives/pydio-core-${PYDIO_VERSION}.tar.gz"
tar -C ${WWW_DIR} -xzf pydio-core-${PYDIO_VERSION}.tar.gz
mv ${WWW_DIR}/pydio-core-${PYDIO_VERSION} ${WWW_DIR}/pydio
rm -f pydio-core-${PYDIO_VERSION}.tar.gz
# php.ini 수정
PHP_VER=$(php --version | head -n 1 | cut -d " " -f 2 | cut -c 1-3)
cp -f /etc/php/${PHP_VER}/apache2/php.ini /etc/php/${PHP_VER}/apache2/php.ini.${TIMESTAMP}
sed -i "s/^output_buffering = 4096/output_buffering = off/g" /etc/php/${PHP_VER}/apache2/php.ini
# Session 경로 설정
cp -f ${WWW_DIR}/pydio/conf/bootstrap_conf.php ${WWW_DIR}/pydio/conf/bootstrap_conf.php.${TIMESTAMP}
sed -i "s/^\/\/\$AJXP_INISET\[\"session\.save_path\"\] = AJXP_DATA_PATH\.\"\/tmp\/sessions\"/\$AJXP_INISET\[\"session\.save_path\"\] = \"\/tmp\"/g" ${WWW_DIR}/pydio/conf/bootstrap_conf.php
# 코드셋 설정
sed -i "s/^\/\/define(\"AJXP_LOCALE\", \"en_EN\.UTF-8\")/define(\"AJXP_LOCALE\", \"ko_KR\.UTF-8\")/g" ${WWW_DIR}/pydio/conf/bootstrap_conf.php
# "Deprecated: Function get_magic_quotes_gpc() in PHP 7.4" 오류 수정
sync
cp -f ${WWW_DIR}/pydio/core/src/pydio/Tests/PHP_magic_quotes.php ${WWW_DIR}/pydio/core/src/pydio/Tests/PHP_magic_quotes.php.${TIMESTAMP}
cp -f ${WWW_DIR}/pydio/core/src/pydio/Core/Utils/Vars/InputFilter.php ${WWW_DIR}/pydio/core/src/pydio/Core/Utils/Vars/InputFilter.php.${TIMESTAMP}
sed -i "s/get_magic_quotes_gpc()/false/g" ${WWW_DIR}/pydio/core/src/pydio/Tests/PHP_magic_quotes.php
sed -i "s/get_magic_quotes_gpc()/false/g" ${WWW_DIR}/pydio/core/src/pydio/Core/Utils/Vars/InputFilter.php
# 공용파일 디렉토리 링크
rm -rf ${WWW_DIR}/pydio/data/files
ln -sf ${STORAGE_MOUNT_DIR} ${WWW_DIR}/pydio/data/files
chown -R www-data:www-data ${WWW_DIR}
fi
}
install_vaultwarden() {
echo "###########################################################"
echo "#"
echo "# vaultwarden(bitwarden unofficial 버전) 설치"
echo "# https://github.com/dani-garcia/vaultwarden"
echo "#"
echo "###########################################################"
if [ ${USE_BITWARDEN} = 1 ]
then
# docker 이미지 정리 및 제거
docker stop $(docker ps -a -q)
docker rm -f $(docker ps -a -q)
docker rmi -f $(docker images -a -q)
# vaultwarden 설치 이미지 정리
docker pull vaultwarden/server:latest
mkdir -p /var/lib/vaultwarden
rm -rf /var/lib/vaultwarden/*
# Let's encrypt 인증서를 사용하여 5443포트로 실행한다.
# Let's encrypt 사용시 cert.pem은 fullchain.pem으로 교체하여 사용
docker run -d --name vaultwarden -e ROCKET_TLS="{certs=\"/ssl/live/hasu0707.duckdns.org/cert.pem\",key=\"/ssl/live/hasu0707.duckdns.org/privkey.pem\"}" -v /etc/letsencrypt/:/ssl/ -v /var/lib/vaultwarden/:/data/ -p 5443:80 vaultwarden/server:latest
# systemd 서비스 등록
echo "[Unit]" > /lib/systemd/system/docker-vaultwarden.service
echo "Wants=docker.service" >> /lib/systemd/system/docker-vaultwarden.service
echo "After=docker.service" >> /lib/systemd/system/docker-vaultwarden.service
echo "" >> /lib/systemd/system/docker-vaultwarden.service
echo "[Service]" >> /lib/systemd/system/docker-vaultwarden.service
echo "RemainAfterExit=yes" >> /lib/systemd/system/docker-vaultwarden.service
echo "ExecStart=/usr/bin/docker start vaultwarden" >> /lib/systemd/system/docker-vaultwarden.service
echo "ExecStop=/usr/bin/docker stop vaultwarden" >> /lib/systemd/system/docker-vaultwarden.service
echo "" >> /lib/systemd/system/docker-vaultwarden.service
echo "[Install]" >> /lib/systemd/system/docker-vaultwarden.service
echo "WantedBy=multi-user.target" >> /lib/systemd/system/docker-vaultwarden.service
ln -sf /lib/systemd/system/docker-vaultwarden.service /etc/systemd/system/docker-vaultwarden.service
systemctl daemon-reload
systemctl enable docker-vaultwarden.service
fi
}
install_extplorer() {
echo "###########################################################"
echo "#"
echo "# eXtplorer 설치"
echo "#"
echo "###########################################################"
if [ ${USE_EXTPLORER} = 1 ]
then
cd ${CURRENT_DIR}
wget "http://extplorer.net/attachments/download/94/eXtplorer_${EXTPLORER_VERSION}.zip"
mkdir -p ${WWW_DIR}/extplorer
unzip -d ${WWW_DIR}/extplorer eXtplorer_${EXTPLORER_VERSION}.zip
rm -f eXtplorer_${EXTPLORER_VERSION}.zip
tar -C ${WWW_DIR}/extplorer -xzf ${WWW_DIR}/extplorer/scripts.tar.gz
chown -R www-data:www-data ${WWW_DIR}
fi
}
setup_apache2_index() {
echo "###########################################################"
echo "#"
echo "# index.html, phpinfo.php 작성"
echo "#"
echo "###########################################################"
echo '<!DOCTYPE html>' > ${WWW_DIR}/index.php
echo "<html lang=\"ko\">" >> ${WWW_DIR}/index.php
echo " <head>" >> ${WWW_DIR}/index.php
echo " <meta charset=\"UTF-8\">" >> ${WWW_DIR}/index.php
echo " <title>${BOARD_NAME}</title>" >> ${WWW_DIR}/index.php
echo " </head>" >> ${WWW_DIR}/index.php
echo " <body><ul>" >> ${WWW_DIR}/index.php
if [ ${USE_PYDIO} = 1 ]
then
echo " <li><a href=\"/pydio/\" target=\"_blank\">Pydio - Enterprise File Sharing & Sync Platform</a></li>" >> ${WWW_DIR}/index.php
fi
if [ ${USE_EXTPLORER} = 1 ]
then
echo " <li><a href=\"/extplorer/\" target=\"_blank\">eXtplorer - a PHP-based File Manager</a></li>" >> ${WWW_DIR}/index.php
fi
echo " </ul></body>" >> ${WWW_DIR}/index.php
echo "</html>" >> ${WWW_DIR}/index.php
if [ ${USE_PHP} = 1 ]
then
echo '<?php phpinfo(); ?>' > ${WWW_DIR}/phpinfo.php
fi
}
make_working_dir() {
echo "###########################################################"
echo "#"
echo "# 디폴트 외장하드 마운트 디렉토리 생성"
echo "#"
echo "###########################################################"
mkdir -p ${NEW_USER_HOME}
chmod 755 ${NEW_USER_HOME}
chown -R ${NEW_USER}:${NEW_GROUP} ${NEW_USER_HOME}
mkdir -p ${STORAGE_MOUNT_DIR}
chmod 755 ${STORAGE_MOUNT_DIR}
chown -R ${NEW_USER}:${NEW_GROUP} ${STORAGE_MOUNT_DIR}
mkdir ${AUTOFS_DIR}
}
set_fstab() {
echo "###########################################################"
echo "#"
echo "# 외장 하드디스크 마운트 등록"
echo "#"
echo "###########################################################"
mkdir -p ${STORAGE_MOUNT_DIR}
echo "" >> /etc/fstab
echo "# Storage" >> /etc/fstab
echo "#/dev/disk/by-id/ata-ST4000DM004-2CV104_WFN5L8WV-part1 ${STORAGE_MOUNT_DIR} ntfs-3g defaults 0 5" >> /etc/fstab
echo "#/dev/sda1 ${STORAGE_MOUNT_DIR} ntfs-3g defaults 0 5" >> /etc/fstab
echo "#/dev/sda1 ${STORAGE_MOUNT_DIR} ext4 defaults 0 6" >> /etc/fstab
echo "" >> /etc/fstab
echo "# samba CIFS" >> /etc/fstab
echo "#//192.168.1.10/odroid_hc2 ${STORAGE_MOUNT_DIR} cifs _netdev,username=armbian,password=MYPASSWD,uid=1000,gid=1000,rw,iocharset=utf8 0 0" >> /etc/fstab
echo "#//10.10.10.1/hasu0707 ${STORAGE_MOUNT_DIR}/hasu0707@www.esvali.com cifs _netdev,username=hasu0707,password=MYPASSWD,uid=1000,gid=1000,rw,iocharset=utf8,vers=1.0 0 0" >> /etc/fstab
echo "#//10.10.10.2/share ${STORAGE_MOUNT_DIR}/share@nas.esvali.com cifs _netdev,username=share,password=MYPASSWD,uid=1000,gid=1000,rw,iocharset=utf8,vers=1.0 0 0" >> /etc/fstab
echo "" >> /etc/fstab
echo "# NFS" >> /etc/fstab
echo "#hasu0707.duckdns.org:${STORAGE_MOUNT_DIR} ${STORAGE_MOUNT_DIR}/armbian@hasu0707.duckdns.org nfs defaults,_netdev 0 0" >> /etc/fstab
}
set_default_mount_dir() {
echo "###########################################################"
echo "#"
echo "# 외장 하드디스크 기본 마운트 디렉토리 생성"
echo "#"
echo "###########################################################"
if [ ! -d ${STORAGE_MOUNT_DIR}/0_tmp ]
then
mkdir -p ${STORAGE_MOUNT_DIR}
#mkdir -p "${STORAGE_MOUNT_DIR}/armbian@hasu0707.duckdns.org"
#mkdir -p "${STORAGE_MOUNT_DIR}/hasu0707@www.esvali.com"
#mkdir -p "${STORAGE_MOUNT_DIR}/share@nas.esvali.com"
chown -R ${NEW_USER}:${NEW_GROUP} ${STORAGE_MOUNT_DIR}
fi
}
set_samba() {
echo "###########################################################"
echo "#"
echo "# samba 설정"
echo "#"
echo "###########################################################"
sync
if [ ${USE_SAMBA} = 1 ]
then
echo "" >> /etc/samba/smb.conf
echo "[global]" >> /etc/samba/smb.conf
echo "netbios name = ${BOARD_NAME_SHORT}" >> /etc/samba/smb.conf
echo "workgroup = WORKGROUP" >> /etc/samba/smb.conf
echo "hosts allow = 127. 10.10.10. 192.168.1." >> /etc/samba/smb.conf
echo "#socket options = IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072 TCP_NODELAY" >> /etc/samba/smb.conf
echo "#max xmit = 16644" >> /etc/samba/smb.conf
echo "#read raw = no" >> /etc/samba/smb.conf
echo "#write raw = no" >> /etc/samba/smb.conf
echo "log level = 0" >> /etc/samba/smb.conf
echo "" >> /etc/samba/smb.conf
echo "client ipc min protocol = NT1" >> /etc/samba/smb.conf
echo "client ipc max protocol = SMB3" >> /etc/samba/smb.conf
echo "client min protocol = NT1" >> /etc/samba/smb.conf
echo "client max protocol = SMB3" >> /etc/samba/smb.conf
echo "server min protocol = NT1" >> /etc/samba/smb.conf
echo "server max protocol = SMB3" >> /etc/samba/smb.conf
echo "" >> /etc/samba/smb.conf
echo "[homes]" >> /etc/samba/smb.conf
echo " comment = Home Directories" >> /etc/samba/smb.conf
echo " browseable = no" >> /etc/samba/smb.conf
echo " writable = yes" >> /etc/samba/smb.conf
echo "" >> /etc/samba/smb.conf
echo "[${BOARD_NAME_SHORT}]" >> /etc/samba/smb.conf
echo " comment = ${BOARD_NAME}" >> /etc/samba/smb.conf
echo " path = ${STORAGE_MOUNT_DIR}" >> /etc/samba/smb.conf
echo " browseble = yes" >> /etc/samba/smb.conf
echo " writable = yes" >> /etc/samba/smb.conf
echo " share modes = yes" >> /etc/samba/smb.conf
echo " valid users = ${NEW_USER}" >> /etc/samba/smb.conf
echo " read only = no" >> /etc/samba/smb.conf
echo " create mode = 0660" >> /etc/samba/smb.conf
echo " directory mode = 0770" >> /etc/samba/smb.conf
echo " guest ok = no" >> /etc/samba/smb.conf
echo "" >> /etc/samba/smb.conf
echo "[media]" >> /etc/samba/smb.conf
echo " comment = /media directory" >> /etc/samba/smb.conf
echo " path = /media" >> /etc/samba/smb.conf
echo " browseble = yes" >> /etc/samba/smb.conf
echo " writable = yes" >> /etc/samba/smb.conf
echo " share modes = yes" >> /etc/samba/smb.conf
echo " valid users = ${NEW_USER}" >> /etc/samba/smb.conf
echo " read only = no" >> /etc/samba/smb.conf
echo " create mode = 0660" >> /etc/samba/smb.conf
echo " directory mode = 0770" >> /etc/samba/smb.conf
echo " guest ok = no" >> /etc/samba/smb.conf
sed -i 's/read only = yes/read only = no/g' /etc/samba/smb.conf
sed -i 's/create mask = 0700/create mask = 0755/g' /etc/samba/smb.conf
sed -i 's/directory mask = 0700/directory mask = 0755/g' /etc/samba/smb.conf
sed -i 's/# This might need tweaking when using external authentication schemes/ writable = yes/g' /etc/samba/smb.conf
mkdir -p ${STORAGE_MOUNT_DIR}
chown -R ${NEW_USER}:${NEW_GROUP} ${STORAGE_MOUNT_DIR}
chown -R ${NEW_USER}:${NEW_GROUP} /media
chmod 755 ${STORAGE_MOUNT_DIR}
chmod 755 /media
systemctl daemon-reload
systemctl enable nmbd.service
systemctl enable smbd.service
fi
}
set_dhcpd() {
echo "###########################################################"
echo "#"
echo "# dhcpd 설정"
echo "#"
echo "###########################################################"
sync
echo "ddns-update-style none;" > /etc/dhcp/dhcpd.conf
echo "default-lease-time 86400;" >> /etc/dhcp/dhcpd.conf
echo "max-lease-time 172800;" >> /etc/dhcp/dhcpd.conf
echo "" >> /etc/dhcp/dhcpd.conf
echo "subnet 192.168.1.0 netmask 255.255.255.248 {" >> /etc/dhcp/dhcpd.conf
echo " range 192.168.1.2 192.168.1.6;" >> /etc/dhcp/dhcpd.conf
echo " option domain-name \"local\";" >> /etc/dhcp/dhcpd.conf
echo " option domain-name-servers ${DNS_SERVER1}, ${DNS_SERVER2};" >> /etc/dhcp/dhcpd.conf
echo " option subnet-mask 255.255.255.248;" >> /etc/dhcp/dhcpd.conf
echo " option routers 192.168.1.1;" >> /etc/dhcp/dhcpd.conf
echo " option broadcast-address 192.168.1.7;" >> /etc/dhcp/dhcpd.conf
echo " default-lease-time 86400;" >> /etc/dhcp/dhcpd.conf
echo " max-lease-time 172800;" >> /etc/dhcp/dhcpd.conf
echo "}" >> /etc/dhcp/dhcpd.conf
}
set_vsftpd() {
echo "###########################################################"
echo "#"
echo "# vsftpd 설정"
echo "#"
echo "###########################################################"
if [ ${USE_VSFTPD} = 1 ]
then
echo "allow_writeable_chroot=YES" >> /etc/vsftpd.conf
echo "anon_mkdir_write_enable=NO" >> /etc/vsftpd.conf
echo "anon_upload_enable=NO" >> /etc/vsftpd.conf
echo "anonymous_enable=NO" >> /etc/vsftpd.conf
echo "chroot_local_user=YES" >> /etc/vsftpd.conf
echo "file_open_mode=0644" >> /etc/vsftpd.conf
echo "force_dot_files=NO" >> /etc/vsftpd.conf
echo "listen=YES" >> /etc/vsftpd.conf
echo "listen_ipv6=NO" >> /etc/vsftpd.conf
echo "local_enable=YES" >> /etc/vsftpd.conf
echo "local_umask=0002" >> /etc/vsftpd.conf
echo "write_enable=YES" >> /etc/vsftpd.conf
echo >> /etc/vsftpd.conf
echo "# Passive Mode" >> /etc/vsftpd.conf
echo "pasv_enable=YES" >> /etc/vsftpd.conf
echo "pasv_min_port=5500" >> /etc/vsftpd.conf
echo "pasv_max_port=5532" >> /etc/vsftpd.conf
echo >> /etc/vsftpd.conf
echo "# Setup the virtual users config folder" >> /etc/vsftpd.conf
echo "user_config_dir=/etc/vsftpd/user_config_dir/" >> /etc/vsftpd.conf
mkdir -p /etc/vsftpd/user_config_dir
echo "local_root=${STORAGE_MOUNT_DIR}" > /etc/vsftpd/user_config_dir/${NEW_USER}
echo "write_enable=YES" >> /etc/vsftpd/user_config_dir/${NEW_USER}
systemctl daemon-reload
systemctl enable vsftpd.service
echo "nf_conntrack_ftp" >> /etc/modules
fi
}
set_apache2() {
echo "###########################################################"
echo "#"
echo "# apache2 설정"
echo "#"
echo "###########################################################"
if [ ${USE_APACHE2} = 1 ]
then
echo "" >> /etc/apache2/apache2.conf
echo "IndexOptions IgnoreCase FancyIndexing FoldersFirst NameWidth=* DescriptionWidth=* SuppressHTMLPreamble" >> /etc/apache2/apache2.conf
echo "# opizero2에서 Mutex 옵션이 없으면 작동하지 않는다." >> /etc/apache2/apache2.conf
echo "Mutex posixsem" >> /etc/apache2/apache2.conf
# 포트 변경 및 추가
sed -i "s/Listen 80/Listen ${HTTP_PORT}/g" /etc/apache2/ports.conf
if [ ${USE_WEBDAV} = 1 ]
then
echo "Listen ${WEBDAV_PORT}" >> /etc/apache2/ports.conf
fi
# /etc/apache2/sites-available/${MY_SITE}-webdav.conf
if [ ${USE_WEBDAV} = 1 ]
then
echo "DavLockDB ${NEW_USER_HOME}/DavLock" > /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo "<VirtualHost _default_:${WEBDAV_PORT}>" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " ServerAdmin ${NEW_USER}@localhost" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " DocumentRoot \"${STORAGE_MOUNT_DIR}\"" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " ErrorLog \${APACHE_LOG_DIR}/webdav_error.log" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " CustomLog \${APACHE_LOG_DIR}/webdav_access.log combined" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " Alias /webdav ${STORAGE_MOUNT_DIR}" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " <Directory \"${STORAGE_MOUNT_DIR}\">" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " DAV On" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " Options Indexes FollowSymLinks MultiViews" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " AuthType Digest" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " AuthName webdav" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " AuthUserFile /etc/apache2/users.password" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " Require valid-user" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " </Directory>" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " # SSL" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " SSLEngine on" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
if [ ${USE_LETSENCRYPT} = 1 ]
then
echo " SSLCertificateFile /etc/letsencrypt/live/${LETSENCRYPT_DOMAIN}/cert.pem" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " SSLCertificateKeyFile /etc/letsencrypt/live/${LETSENCRYPT_DOMAIN}/privkey.pem" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " SSLCertificateChainFile /etc/letsencrypt/live/${LETSENCRYPT_DOMAIN}/chain.pem" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
else
echo " SSLCertificateFile /etc/apache2/ssl/certs/ssl-cert-${MY_SITE}.crt" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " SSLCertificateKeyFile /etc/apache2/ssl/private/ssl-cert-${MY_SITE}.key" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
fi
echo " SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " <FilesMatch \"\\.(cgi|shtml|phtml|php)\$\">" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " SSLOptions +StdEnvVars" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " </FilesMatch>" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " <Directory /usr/lib/cgi-bin>" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " SSLOptions +StdEnvVars" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo " </Directory>" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
echo "</VirtualHost>" >> /etc/apache2/sites-available/${MY_SITE}-webdav.conf
a2ensite ${MY_SITE}-webdav
fi
# /etc/apache2/sites-available/${MY_SITE}-http.conf
echo "<VirtualHost _default_:80>" > /etc/apache2/sites-available/${MY_SITE}-http.conf
echo " ServerAdmin ${NEW_USER}@localhost" >> /etc/apache2/sites-available/${MY_SITE}-http.conf
echo " DocumentRoot \"${WWW_DIR}\"" >> /etc/apache2/sites-available/${MY_SITE}-http.conf
echo " ErrorLog \${APACHE_LOG_DIR}/error.log" >> /etc/apache2/sites-available/${MY_SITE}-http.conf
echo " CustomLog \${APACHE_LOG_DIR}/access.log combined" >> /etc/apache2/sites-available/${MY_SITE}-http.conf
echo " <Directory \"${WWW_DIR}\">" >> /etc/apache2/sites-available/${MY_SITE}-http.conf
echo " Options Indexes FollowSymLinks MultiViews ExecCGI" >> /etc/apache2/sites-available/${MY_SITE}-http.conf
echo " AllowOverride FileInfo AuthConfig Limit" >> /etc/apache2/sites-available/${MY_SITE}-http.conf
echo " Order Deny,Allow" >> /etc/apache2/sites-available/${MY_SITE}-http.conf
echo " Allow from all" >> /etc/apache2/sites-available/${MY_SITE}-http.conf
echo " Require all granted" >> /etc/apache2/sites-available/${MY_SITE}-http.conf
echo " </Directory>" >> /etc/apache2/sites-available/${MY_SITE}-http.conf
echo "</VirtualHost>" >> /etc/apache2/sites-available/${MY_SITE}-http.conf
a2dissite 000-default
a2ensite ${MY_SITE}-http
# /etc/apache2/sites-available/${MY_SITE}-https.conf
echo "<IfModule mod_ssl.c>" > /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " <VirtualHost _default_:443>" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " ServerAdmin ${NEW_USER}@localhost" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " DocumentRoot \"${WWW_DIR}\"" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " ErrorLog \${APACHE_LOG_DIR}/error.log" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " CustomLog \${APACHE_LOG_DIR}/access.log combined" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " <Directory \"${WWW_DIR}\">" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " Options Indexes FollowSymLinks MultiViews ExecCGI" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " AllowOverride FileInfo AuthConfig Limit" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " Order Deny,Allow" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " Allow from all" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " Require all granted" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " </Directory>" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " SSLEngine on" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
if [ ${USE_LETSENCRYPT} = 1 ]
then
echo " SSLCertificateFile /etc/letsencrypt/live/${LETSENCRYPT_DOMAIN}/cert.pem" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " SSLCertificateKeyFile /etc/letsencrypt/live/${LETSENCRYPT_DOMAIN}/privkey.pem" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " SSLCertificateChainFile /etc/letsencrypt/live/${LETSENCRYPT_DOMAIN}/chain.pem" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
else
echo " SSLCertificateFile /etc/apache2/ssl/certs/ssl-cert-${MY_SITE}.crt" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " SSLCertificateKeyFile /etc/apache2/ssl/private/ssl-cert-${MY_SITE}.key" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
fi
echo " <FilesMatch \"\\.(cgi|shtml|phtml|php)\$\">" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " SSLOptions +StdEnvVars" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " </FilesMatch>" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " <Directory /usr/lib/cgi-bin>" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " SSLOptions +StdEnvVars" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " </Directory>" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo " </VirtualHost>" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
echo "</IfModule>" >> /etc/apache2/sites-available/${MY_SITE}-https.conf
a2dissite default-ssl
a2ensite ${MY_SITE}-https
sed -i "s/ServerName/#ServerName/g" /etc/apache2/apache2.conf
echo "" >> /etc/apache2/apache2.conf
if [ ${USE_LETSENCRYPT} = 1 ]
then
echo "ServerName ${LETSENCRYPT_DOMAIN}" >> /etc/apache2/apache2.conf
else
echo "ServerName localhost" >> /etc/apache2/apache2.conf
fi
chown -R www-data:www-data ${WWW_DIR}
chown www-data:www-data /etc/apache2/users.password
fi
}
set_letsencrypt() {
echo "###########################################################"
echo "#"
echo "# Let's encrypt 설정파일 생성"
echo "#"
echo "###########################################################"
if [ ${USE_LETSENCRYPT} = 1 ]
then
echo "archive_dir = /etc/letsencrypt/archive/${LETSENCRYPT_DOMAIN}" > /etc/letsencrypt/renewal/${LETSENCRYPT_DOMAIN}.conf
echo "cert = /etc/letsencrypt/live/${LETSENCRYPT_DOMAIN}/cert.pem" >> /etc/letsencrypt/renewal/${LETSENCRYPT_DOMAIN}.conf
echo "privkey = /etc/letsencrypt/live/${LETSENCRYPT_DOMAIN}/privkey.pem" >> /etc/letsencrypt/renewal/${LETSENCRYPT_DOMAIN}.conf
echo "chain = /etc/letsencrypt/live/${LETSENCRYPT_DOMAIN}/chain.pem" >> /etc/letsencrypt/renewal/${LETSENCRYPT_DOMAIN}.conf
echo "fullchain = /etc/letsencrypt/live/${LETSENCRYPT_DOMAIN}/fullchain.pem" >> /etc/letsencrypt/renewal/${LETSENCRYPT_DOMAIN}.conf
fi
}
set_timezone_locale() {
echo "###########################################################"
echo "#"
echo "# timezone & locale"
echo "#"
echo "###########################################################"
${APTCMD} -y install language-pack-ko
locale-gen ko_KR.UTF-8
update-locale LC_ALL="ko_KR.UTF-8" LANG="ko_KR.UTF-8" LANGUAGE="ko_KR:ko:en_US:en" LC_MESSAGES="POSIX"
timedatectl set-timezone "Asia/Seoul"
}
set_sshd() {
echo "###########################################################"
echo "#"
echo "# /etc/ssh/sshd_config 수정"
echo "#"
echo "###########################################################"
sed -i "s/PermitRootLogin without-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
}
set_os_default_systemd() {
echo "###########################################################"
echo "#"
echo "# 불필요한 서비스 제거"
echo "#"
echo "# enable 되어있는 서비스 보기"
echo "# ls -1 /etc/rc\$(runlevel| cut -d\" \" -f2).d/S* | awk -F'[0-9][0-9]' '{print \"Startup :-> \" \$2}'"
echo "# systemctl -t service -a"
echo "# systemctl list-unit-files"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
# rc.local 활성화
echo "" >> /lib/systemd/system/rc-local.service
echo "[Install]" >> /lib/systemd/system/rc-local.service
echo "WantedBy=multi-user.target" >> /lib/systemd/system/rc-local.service
systemctl daemon-reload
systemctl disable acpid.service
systemctl disable alsa-utils.service
systemctl disable ${NEW_USER}-hardware-monitor.service
systemctl disable ${NEW_USER}-ramlog.service
systemctl disable avahi-daemon.service
systemctl disable bluetooth.service
systemctl disable hddtemp.service
systemctl disable hostapd.service
systemctl disable isc-dhcp-server.service
systemctl disable isc-dhcp-server6.service
systemctl disable pppd-dns.service
systemctl disable rsync.service
systemctl disable samba-ad-dc.service
systemctl disable sysstat.service
systemctl disable udhcpd.service
systemctl disable ureadahead.service
systemctl enable cron.service
systemctl enable dbus.service
systemctl enable rc-local.service
systemctl enable resolvconf.service
systemctl enable rsyslog.service
systemctl enable ssh.service
systemctl daemon-reload
}
set_ntpd() {
echo "###########################################################"
echo "#"
echo "# ntp 서비스 설정"
echo "#"
echo "###########################################################"
sed -i "s/0.ubuntu.pool.ntp.org/3.kr.pool.ntp.org/g" /etc/ntp.conf
sed -i "s/1.ubuntu.pool.ntp.org/0.asia.pool.ntp.org/g" /etc/ntp.conf
sed -i "s/2.ubuntu.pool.ntp.org/3.asia.pool.ntp.org/g" /etc/ntp.conf
sed -i "s/3.ubuntu.pool.ntp.org/1.kr.pool.ntp.org/g" /etc/ntp.conf
systemctl daemon-reload
systemctl enable ntp.service
}
set_eth0_device_name() {
echo "###########################################################"
echo "#"
echo "# 이더넷 인터페이스 명을 eth0로 바꾼다."
echo "#"
echo "###########################################################"
# ODROID-HC2 (enx*602)
if [[ ${BOARD_NAME_SHORT} = "odroid_hc2" ]]
then
echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*|enx*\", NAME=\"eth0\"" > /lib/udev/rules.d/70-persistent-net.rules
fi
}
set_board_name() {
echo "###########################################################"
echo "#"
echo "# Login ASCII Art를 변경하기 위해 보드명을 수정한다."
echo "#"
echo "###########################################################"
sed -i "s/BOARD_NAME=/#BOARD_NAME=/g" /etc/${NEW_USER}-release
echo "BOARD_NAME=\"${BOARD_NAME}\"" >> /etc/${NEW_USER}-release
}
set_usb_device_name() {
echo "###########################################################"
echo "#"
echo "# USB 네트워크 인터페이스 이름변경 금지"
echo "#"
echo "###########################################################"
mv /lib/udev/rules.d/73-usb-net-by-mac.rules /lib/udev/rules.d/73-usb-net-by-mac.rules.no_run
}
set_hostname() {
echo "###########################################################"
echo "#"
echo "# 호스트명 설정"
echo "#"
echo "###########################################################"
echo "${BOARD_NAME_SHORT}" > /etc/hostname
}
set_insserv() {
echo "###########################################################"
echo "#"
echo "# insserv를 /usr/bin으로 복사"
echo "#"
echo "###########################################################"
cp -f /usr/lib/insserv/insserv /usr/bin
}
set_mount_opt() {
echo "###########################################################"
echo "#"
echo "# 마운트 옵션 변경"
echo "#"
echo "###########################################################"
sed -i "s/noatime,nodiratime,commit=600,/sync,dirsync,/g" /etc/fstab
}
resize_partition() {
echo "###########################################################"
echo "#"
echo "# Resize Partition"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
systemctl enable resize2fs
update-rc.d resize2fs defaults
}
clean_tmps() {
cd ${CURRENT_DIR}
echo "###########################################################"
echo "#"
echo "# 불필요한 파일들 삭제"
echo "#"
echo "###########################################################"
deb_clean
rm -f /var/log/*.gz
rm -f /var/log/*.log.*
rm -f /var/log/*log
rm -f /var/log/syslog
rm -f /var/swap
rm -rf /tmp/*
rm -f /var/log/xrdp*
touch /var/log/xrdp.log
chown xrdp:adm /var/log/xrdp.log
chmod 640 /var/log/xrdp.log
sync
}
set_inittab() {
echo "###########################################################"
echo "#"
echo "# 초기 부팅모드 설정 (inittab 3 or 5 ?)"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
systemctl disable lightdm.service
systemctl set-default multi-user.target
}
set_rclocal() {
echo "###########################################################"
echo "#"
echo "# rc.local 셋팅"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
grep "firewall_${BOARD_NAME_SHORT}.sh" /etc/rc.local > /dev/null
if [ $? -ne 0 ]
then
sed -i "/exit 0/d" /etc/rc.local
echo "###########################################################" >> /etc/rc.local
echo "#" >> /etc/rc.local
echo "# Run Firewall Script" >> /etc/rc.local
echo "#" >> /etc/rc.local
echo "###########################################################" >> /etc/rc.local
echo "if [ -f /root/scripts/firewall_${BOARD_NAME_SHORT}.sh ]; then" >> /etc/rc.local
echo " /root/scripts/firewall_${BOARD_NAME_SHORT}.sh start" >> /etc/rc.local
echo "fi" >> /etc/rc.local
echo "" >> /etc/rc.local
echo "# Enable Wifi Device" >> /etc/rc.local
echo "#/usr/sbin/rfkill unblock all" >> /etc/rc.local
echo "#/usr/sbin/ifup wlan0" >> /etc/rc.local
echo "" >> /etc/rc.local
echo "exit 0" >> /etc/rc.local
else
echo "이미 편집 되었습니다."
fi
}
set_apache2_ssl() {
cd ${CURRENT_DIR}
echo "###########################################################"
echo "#"
echo "# apache2의 80포트를 disable 하고 SSL을 적용한다."
echo "#"
echo "###########################################################"
echo "######################################################################"
echo "# apache SSL 초기화"
echo "######################################################################"
rm -rf /etc/apache2/ssl/*
echo "######################################################################"
echo "# ntpdate 시간 동기화"
echo "######################################################################"
ntpdate -v kr.pool.ntp.org
echo "######################################################################"
echo "# 32바이트짜리 랜덤 파일 생성"
echo "######################################################################"
head -c 32 < /dev/random > ~/.rnd
echo "######################################################################"
echo "# 개인키를 생성한다."
echo "# (생성 시 해당 키의 비밀번호를 2번 입력해 준다)"
echo "######################################################################"
openssl genrsa -des3 -out ssl-cert-${MY_SITE}.key 2048
echo "######################################################################"
echo "# 서버 인증서 발급을 위한 요청 파일인"
echo "# CSR(Certificate Sinning Request-인증서 서명 요청)을 생성"
echo "# (개인키의 비밀번호를 입력한다)"
echo "######################################################################"
openssl req -new -days 18250 -key ssl-cert-${MY_SITE}.key -out ssl-cert-${MY_SITE}.csr -subj "/C=KR/ST=Seoul/L=Guro-gu/O=My Office/OU=Web Server/CN=${MY_SITE}"
echo "######################################################################"
echo "# 편의를 위해 개인키 암호 제거"
echo "# (개인키의 비밀번호를 입력한다)"
echo "######################################################################"
cp -fv ssl-cert-${MY_SITE}.key ssl-cert-${MY_SITE}.key.orig
openssl rsa -in ssl-cert-${MY_SITE}.key.orig -out ssl-cert-${MY_SITE}.key
echo "######################################################################"
echo "# 서버 개인키와 CSR을 사용해서 인증서에 서명"
echo "######################################################################"
openssl x509 -req -days 18250 -in ssl-cert-${MY_SITE}.csr -signkey ssl-cert-${MY_SITE}.key -out ssl-cert-${MY_SITE}.crt
mkdir -p /etc/apache2/ssl/private
mkdir -p /etc/apache2/ssl/certs
mv -fv ${CURRENT_DIR}/ssl-cert-${MY_SITE}.key* /etc/apache2/ssl/private/
mv -fv ${CURRENT_DIR}/ssl-cert-${MY_SITE}.crt /etc/apache2/ssl/certs/
mv -fv ${CURRENT_DIR}/ssl-cert-${MY_SITE}.csr /etc/apache2/ssl/certs/
}
set_sshd_ciphers() {
clear
cd ${CURRENT_DIR}
echo "###########################################################"
echo "#"
echo "# sshd 암호화 알고리즘 낮은 보안수준으로 변경"
echo "#"
echo "###########################################################"
echo "HostKeyAlgorithms ssh-dss,ssh-rsa" > /etc/ssh/sshd_config.d/lowlevel_ciphers.conf
echo "KexAlgorithms diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1" >> /etc/ssh/sshd_config.d/lowlevel_ciphers.conf
}
set_passwords() {
clear
cd ${CURRENT_DIR}
echo "###########################################################"
echo "#"
echo "# 패스워드 설정"
echo "#"
echo "###########################################################"
rm -f /etc/apache2/users.password
if [ ${USE_WEBDAV} = 1 ]
then
echo "###########################################################"
echo "#"
echo "# ENTER WEBDAV PASSWORD (USER:${NEW_USER})"
echo "#"
echo "###########################################################"
htdigest -c /etc/apache2/users.password webdav ${NEW_USER}
chown www-data:www-data /etc/apache2/users.password
fi
if [ ${USE_SAMBA} = 1 ]
then
echo "###########################################################"
echo "#"
echo "# ENTER SAMBA PASSWORD (USER:${NEW_USER})"
echo "#"
echo "###########################################################"
smbpasswd -a ${NEW_USER}
fi
if [ ${USE_VNC_SERVER} = 1 ]
then
echo "###########################################################"
echo "#"
echo "# ENTER vncserver PASSWORD (vncserver :1)"
echo "#"
echo "###########################################################"
su - -c /usr/bin/vncpasswd ${NEW_USER}
fi
if [ ${USE_TRANSMISSION} = 1 ]
then
systemctl stop transmission-daemon
echo "###########################################################"
echo "#"
echo "# ENTER transmission-daemon PASSWORD"
echo "# ${NEW_USER_HOME}/.config/transmission-daemon/settings.json"
echo "#"
echo "###########################################################"
echo -n "NEW PASSWORD: "
read TRANSMISSIONPW
sed -i '/\"rpc-password\":/d' ${NEW_USER_HOME}/.config/transmission-daemon/settings.json
sed -i "s/}/ ,\"rpc-password\": \"${TRANSMISSIONPW}\"\n}/g" ${NEW_USER_HOME}/.config/transmission-daemon/settings.json
fi
mkdir -p /var/log/apache2
chown ${NEW_USER}:${NEW_GROUP} /var/log/apache2
}
set_keyboard_layout() {
echo "###########################################################"
echo "#"
echo "# 키보드 레이아웃 설정"
echo "#"
echo "###########################################################"
sed -i "s/XKBMODEL/#XKBMODEL/g" /etc/default/keyboard
sed -i "s/XKBLAYOUT/#XKBLAYOUT/g" /etc/default/keyboard
sed -i "s/XKBVARIANT/#XKBVARIANT/g" /etc/default/keyboard
sed -i "s/XKBOPTIONS/#XKBOPTIONS/g" /etc/default/keyboard
sed -i "s/BACKSPACE/#BACKSPACE/g" /etc/default/keyboard
echo "" >> /etc/default/keyboard
echo 'XKBMODEL="pc105"' >> /etc/default/keyboard
echo 'XKBLAYOUT="kr(kr104)"' >> /etc/default/keyboard
echo 'XKBVARIANT=""' >> /etc/default/keyboard
echo 'XKBOPTIONS=""' >> /etc/default/keyboard
dpkg-reconfigure keyboard-configuration
}
set_optimize_systemd() {
echo "###########################################################"
echo "#"
echo "# 보드 용도에 맞게 systemd 서비스 셋팅"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
systemctl daemon-reload
case ${BOARD_NAME_SHORT} in
"opizero")
echo "이 보드는 opizero 입니다."
systemctl disable autofs.service
systemctl disable bluetooth.service
systemctl enable apache2.service
systemctl enable mysql.service
systemctl disable nfs-kernel-server
systemctl disable nmbd.service
systemctl disable rpcbind.service
systemctl disable smbd.service
systemctl disable vsftpd.service
systemctl disable transmission-daemon.service
systemctl disable docker
systemctl disable plexmediaserver
systemctl disable rpimonitor
;;
"opizero2")
echo "이 보드는 opizero2 입니다."
systemctl disable autofs.service
systemctl disable bluetooth.service
systemctl enable apache2.service
systemctl enable mysql.service
systemctl disable nfs-kernel-server
systemctl enable nmbd.service
systemctl disable rpcbind.service
systemctl enable smbd.service
systemctl disable vsftpd.service
systemctl enable transmission-daemon.service
systemctl disable docker
systemctl disable plexmediaserver
systemctl disable rpimonitor
;;
"odroid_hc2")
echo "이 보드는 odroid_hc2 입니다."
systemctl disable autofs.service
systemctl disable bluetooth.service
systemctl enable apache2.service
systemctl enable mysql.service
systemctl enable nfs-kernel-server
systemctl enable nmbd.service
systemctl enable rpcbind.service
systemctl enable smbd.service
systemctl disable transmission-daemon.service
systemctl enable vsftpd.service
systemctl enable docker
systemctl disable plexmediaserver
systemctl disable rpimonitor
;;
*)
echo "ERROR: Unknown board name."
;;
esac
systemctl daemon-reload
}
set_min_systemd() {
echo "###########################################################"
echo "#"
echo "# 설치된 중요 서비스의 실행을 disable 하여 서비스 최소화"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
systemctl daemon-reload
systemctl disable autofs.service
systemctl disable apache2.service
systemctl disable mysql.service
systemctl disable transmission-daemon.service
systemctl disable nmbd.service
systemctl disable smbd.service
systemctl disable bluetooth.service
systemctl disable nfs-kernel-server
systemctl disable rpcbind.service
systemctl disable vsftpd.service
systemctl disable docker.service
systemctl disable vncserver.service
systemctl disable rpimonitor.service
systemctl daemon-reload
}
set_max_systemd() {
echo "###########################################################"
echo "#"
echo "# 설치된 중요 서비스의 실행을 enable 하여 서비스 최대화"
echo "#"
echo "###########################################################"
cd ${CURRENT_DIR}
systemctl daemon-reload
systemctl disable autofs.service
systemctl enable apache2.service
systemctl enable mysql.service
systemctl enable transmission-daemon.service
systemctl enable nmbd.service
systemctl enable smbd.service
systemctl enable bluetooth.service
systemctl enable nfs-kernel-server
systemctl enable rpcbind.service
systemctl enable vsftpd.service
systemctl enable docker
systemctl daemon-reload
}
run_install() {
echo "###########################################################"
echo "#"
echo "# Install"
echo "#"
echo "###########################################################"
get_pydiouser_pw
set_ubuntu_repo
dpkg_init
update_os
install_additional_repo
install_apt_get_pkgs
set_locale
set_timezone
set_default_user_account
set_network
set_eth0_device_name
set_dns
set_vim
install_rclone
install_apache2
install_mariadb
install_php
install_letsencrypt
install_vsftpd
install_samba
install_transmission_daemon
install_nfs_server
install_xwindow
install_vncserver
install_xrdp
install_hangul_ime
install_audio
setup_pydio_db
install_pydio
install_extplorer
install_docker
setup_apache2_index
make_working_dir
set_fstab
set_samba
set_dhcpd
set_vsftpd
set_apache2
set_timezone_locale
set_sshd
set_os_default_systemd
set_ntpd
set_usb_device_name
set_hostname
set_insserv
set_mount_opt
set_board_name
set_rclocal
set_sshd_ciphers
set_letsencrypt
update_os
set_keyboard_layout
resize_partition
set_inittab
set_default_mount_dir
install_plexmediaserver
install_vaultwarden
apt purge unattended-upgrades -y
clean_tmps
copy_skel_profile
sync
if [ ${USE_APACHE2} = 1 ]
then
set_apache2_ssl
fi
set_passwords
# iptables 선택 (iptables-legacy로 선택한다)
update-alternatives --config iptables
}
echo "###########################################################"
echo "#"
echo "# Single Board Computer 최적화 스크립트 시작"
echo "#"
echo "###########################################################"
check_board_name
case "$1" in
install)
run_install
set_optimize_systemd
;;
min)
set_min_systemd
;;
max)
set_max_systemd
;;
systemd)
set_optimize_systemd
;;
ssl)
set_apache2_ssl
;;
update)
update_os
;;
test)
# 함수 테스트는 아래를 수정한다.
systemctl restart apache2
;;
*)
echo "Usage: $0 install|min|max|systemd|ssl|update" >&2
exit 1
;;
esac
sync
sync