-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c397e85
Showing
13 changed files
with
1,019 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 DirtyHarryDev | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Yiimp Server Setup | ||
|
||
Installation files for Yiimp Server Installer | ||
|
||
#### These files do nothing on their own please go to https://github.com/DirtyHarryDev/Yiimp-Server-Installer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
################################################################################ | ||
# Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox # | ||
# Updated by Dirty Harry for YiiMP use... # | ||
# This script is intended to be ran from the Yiimp Server Installer # | ||
################################################################################ | ||
|
||
if [ -z "${TAG}" ]; then | ||
TAG=v1.0 | ||
fi | ||
|
||
# Clone the MultiPool repository if it doesn't exist. | ||
if [ ! -d $HOME/yiimpserver/yiimp_multi ]; then | ||
echo Downloading Dirty Harry Yiimp Multi Server Installer ${TAG}. . . | ||
git clone \ | ||
-b ${TAG} --depth 1 \ | ||
https://github.com/DirtyHarryDev/server_yiimp_multi \ | ||
$HOME/yiimpserver/yiimp_multi \ | ||
< /dev/null 2> /dev/null | ||
|
||
echo | ||
fi | ||
|
||
# Change directory to it. | ||
cd $HOME/yiimpserver/yiimp_multi | ||
|
||
# Update it. | ||
sudo chown -R $USER $HOME/yiimpserver/install/.git/ | ||
if [ "${TAG}" != `git describe --tags` ]; then | ||
echo Updating Dirty Harry Yiimp Multi Server Installer to ${TAG} . . . | ||
git fetch --depth 1 --force --prune origin tag ${TAG} | ||
if ! git checkout -q ${TAG}; then | ||
echo "Update failed. Did you modify something in `pwd`?" | ||
exit | ||
fi | ||
echo | ||
fi | ||
|
||
# Start setup script. | ||
cd $HOME/yiimpserver/yiimp_multi | ||
source start.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
################################################################################ | ||
# Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox # | ||
# Updated by Dirty Harry for YiiMP use... # | ||
# This script is intended to be ran from the Yiimp Server Installer # | ||
################################################################################ | ||
|
||
if [ -z "${TAG}" ]; then | ||
TAG=v1.0 | ||
fi | ||
|
||
# Clone the Yiimp repository if it doesn't exist. | ||
if [ ! -d $HOME/yiimpserver/yiimp_single ]; then | ||
echo Downloading Dirty Harry Yiimp Single Server Installer ${TAG}. . . | ||
git clone \ | ||
-b ${TAG} --depth 1 \ | ||
https://github.com/DirtyHarryDev/server_yiimp_single \ | ||
$HOME/yiimpserver/yiimp_single \ | ||
< /dev/null 2> /dev/null | ||
|
||
echo | ||
fi | ||
|
||
# Change directory to it. | ||
cd $HOME/yiimpserver/yiimp_single | ||
|
||
# Update it. | ||
sudo chown -R $USER $HOME/yiimpserver/install/.git/ | ||
if [ "${TAG}" != `git describe --tags` ]; then | ||
echo Updating Dirty Harry Yiimp Single Server Installer to ${TAG} . . . | ||
git fetch --depth 1 --force --prune origin tag ${TAG} | ||
if ! git checkout -q ${TAG}; then | ||
echo "Update failed. Did you modify something in `pwd`?" | ||
exit | ||
fi | ||
echo | ||
fi | ||
|
||
# Start setup script. | ||
cd $HOME/yiimpserver/yiimp_single | ||
source start.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
#!/usr/bin/env bash | ||
|
||
################################################################################ | ||
# Source https://mailinabox.email/ https://github.com/mail-in-a-box/mailinabox # | ||
# Updated by Dirty Harry for YiiMP use... # | ||
# This script is intended to be ran from the Yiimp Server Installer # | ||
################################################################################ | ||
|
||
source /etc/functions.sh | ||
cd ~/yiimpserver/install | ||
clear | ||
|
||
# Welcome | ||
message_box "Dirty Harrys Yiimp Server Setup Installer" \ | ||
"Hello and thanks for using the Dirty Harry´s Crypto-Server Setup Installer! | ||
\n\nInstallation for the most part is fully automated. In most cases any user responses that are needed are asked prior to the installation. | ||
\n\nNOTE: You should only install this on a brand new Ubuntu 16.04 or Ubuntu 18.04 installation." | ||
# Root warning message box | ||
message_box "Dirty Harrys Yiimp Server Setup Installer" \ | ||
"Naughty, naughty! You are trying to install this as the root user! | ||
\n\nRunning any application as root is a serious security risk. | ||
\n\nTherefore we make you create a user account :)" | ||
|
||
# Ask if SSH key or password user | ||
dialog --title "Create New User With SSH Key" \ | ||
--yesno "Do you want to create your new user with SSH key login? | ||
Selecting no will create user with password login only." 7 60 | ||
response=$? | ||
case $response in | ||
0) UsingSSH=yes;; | ||
1) UsingSSH=no;; | ||
255) echo "[ESC] key pressed.";; | ||
esac | ||
|
||
# If Using SSH Key Login | ||
if [[ ("$UsingSSH" == "yes") ]]; then | ||
clear | ||
if [ -z "${yiimpadmin:-}" ]; then | ||
DEFAULT_yiimpadmin=yiimpadmin | ||
input_box "New Account Name" \ | ||
"Please enter your desired user name. | ||
\n\nUser Name:" \ | ||
${DEFAULT_yiimpadmin} \ | ||
yiimpadmin | ||
|
||
if [ -z "${yiimpadmin}" ]; then | ||
# user hit ESC/cancel | ||
exit | ||
fi | ||
fi | ||
|
||
if [ -z "${ssh_key:-}" ]; then | ||
DEFAULT_ssh_key=PublicKey | ||
input_box "Please open PuTTY Key Generator on your local machine and generate a new public key." \ | ||
"To paste your Public key use ctrl shift right click. | ||
\n\nPublic Key:" \ | ||
${DEFAULT_ssh_key} \ | ||
ssh_key | ||
|
||
if [ -z "${ssh_key}" ]; then | ||
# user hit ESC/cancel | ||
exit | ||
fi | ||
fi | ||
|
||
# create random user password | ||
RootPassword=$(openssl rand -base64 8 | tr -d "=+/") | ||
clear | ||
|
||
# Add user | ||
echo -e "Adding new user and setting SSH key...$COL_RESET" | ||
sudo adduser ${yiimpadmin} --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password | ||
echo -e "${RootPassword}\n${RootPassword}" | passwd ${yiimpadmin} | ||
sudo usermod -aG sudo ${yiimpadmin} | ||
# Create SSH Key structure | ||
mkdir -p /home/${yiimpadmin}/.ssh | ||
touch /home/${yiimpadmin}/.ssh/authorized_keys | ||
chown -R ${yiimpadmin}:${yiimpadmin} /home/${yiimpadmin}/.ssh | ||
chmod 700 /home/${yiimpadmin}/.ssh | ||
chmod 644 /home/${yiimpadmin}/.ssh/authorized_keys | ||
authkeys=/home/${yiimpadmin}/.ssh/authorized_keys | ||
echo "$ssh_key" > "$authkeys" | ||
|
||
# enabling yiimpserver command | ||
echo '# yiimp | ||
# It needs passwordless sudo functionality. | ||
'""''"${yiimpadmin}"''""' ALL=(ALL) NOPASSWD:ALL | ||
' | sudo -E tee /etc/sudoers.d/${yiimpadmin} >/dev/null 2>&1 | ||
|
||
echo ' | ||
cd ~/yiimpserver/install | ||
bash start.sh | ||
' | sudo -E tee /usr/bin/yiimpserver >/dev/null 2>&1 | ||
sudo chmod +x /usr/bin/yiimpserver | ||
|
||
# Check required files and set global variables | ||
cd $HOME/yiimpserver/install | ||
source pre_setup.sh | ||
|
||
# Create the STORAGE_USER and STORAGE_ROOT directory if they don't already exist. | ||
if ! id -u $STORAGE_USER >/dev/null 2>&1; then | ||
sudo useradd -m $STORAGE_USER | ||
fi | ||
if [ ! -d $STORAGE_ROOT ]; then | ||
sudo mkdir -p $STORAGE_ROOT | ||
fi | ||
|
||
# Save the global options in /etc/yiimpserver.conf so that standalone | ||
# tools know where to look for data. | ||
echo 'STORAGE_USER='"${STORAGE_USER}"' | ||
STORAGE_ROOT='"${STORAGE_ROOT}"' | ||
PUBLIC_IP='"${PUBLIC_IP}"' | ||
PUBLIC_IPV6='"${PUBLIC_IPV6}"' | ||
DISTRO='"${DISTRO}"' | ||
PRIVATE_IP='"${PRIVATE_IP}"'' | sudo -E tee /etc/yiimpserver.conf >/dev/null 2>&1 | ||
|
||
sudo cp -r ~/yiimpserver /home/${yiimpadmin}/ | ||
cd ~ | ||
sudo setfacl -m u:${yiimpadmin}:rwx /home/${yiimpadmin}/yiimpserver | ||
sudo rm -r $HOME/yiimpserver | ||
clear | ||
echo "New User is installed make sure you saved your private key..." | ||
echo -e "$RED Please reboot system and log in as the new user and type$COL_RESET $GREEN yiimpserver$COL_RESET $RED to continue setup...$COL_RESET" | ||
exit 0 | ||
fi | ||
|
||
# New User Password Login Creation | ||
if [ -z "${yiimpadmin:-}" ]; then | ||
DEFAULT_yiimpadmin=yiimpadmin | ||
input_box "New Account Name" \ | ||
"Please enter your desired user name. | ||
\n\nUser Name:" \ | ||
${DEFAULT_yiimpadmin} \ | ||
yiimpadmin | ||
|
||
if [ -z "${yiimpadmin}" ]; then | ||
# user hit ESC/cancel | ||
exit | ||
fi | ||
fi | ||
|
||
if [ -z "${RootPassword:-}" ]; then | ||
DEFAULT_RootPassword=$(openssl rand -base64 8 | tr -d "=+/") | ||
input_box "User Password" \ | ||
"Enter your new user password or use this randomly system generated one. | ||
\n\nUnfortunatley dialog doesnt let you copy. So you have to write it down. | ||
\n\nUser password:" \ | ||
${DEFAULT_RootPassword} \ | ||
RootPassword | ||
|
||
if [ -z "${RootPassword}" ]; then | ||
# user hit ESC/cancel | ||
exit | ||
fi | ||
fi | ||
|
||
clear | ||
|
||
dialog --title "Verify Your Responses" \ | ||
--yesno "Please verify your answers before you continue: | ||
New User Name : ${yiimpadmin} | ||
New User Pass : ${RootPassword}" 8 60 | ||
|
||
# Get exit status | ||
# 0 means user hit [yes] button. | ||
# 1 means user hit [no] button. | ||
# 255 means user hit [Esc] key. | ||
response=$? | ||
case $response in | ||
|
||
0) | ||
clear | ||
echo -e " Adding new user and password...$COL_RESET" | ||
|
||
sudo adduser ${yiimpadmin} --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password | ||
echo -e ""${RootPassword}"\n"${RootPassword}"" | passwd ${yiimpadmin} | ||
sudo usermod -aG sudo ${yiimpadmin} | ||
|
||
# enabling yiimpserver command | ||
echo '# yiimp | ||
# It needs passwordless sudo functionality. | ||
'""''"${yiimpadmin}"''""' ALL=(ALL) NOPASSWD:ALL | ||
' | sudo -E tee /etc/sudoers.d/${yiimpadmin} >/dev/null 2>&1 | ||
|
||
echo ' | ||
cd ~/yiimpserver/install | ||
bash start.sh | ||
' | sudo -E tee /usr/bin/yiimpserver >/dev/null 2>&1 | ||
sudo chmod +x /usr/bin/yiimpserver | ||
|
||
# Check required files and set global variables | ||
cd $HOME/yiimpserver/install | ||
source pre_setup.sh | ||
|
||
# Create the STORAGE_USER and STORAGE_ROOT directory if they don't already exist. | ||
if ! id -u $STORAGE_USER >/dev/null 2>&1; then | ||
sudo useradd -m $STORAGE_USER | ||
fi | ||
if [ ! -d $STORAGE_ROOT ]; then | ||
sudo mkdir -p $STORAGE_ROOT | ||
fi | ||
|
||
# Save the global options in /etc/yiimpserver.conf so that standalone | ||
# tools know where to look for data. | ||
echo 'STORAGE_USER='"${STORAGE_USER}"' | ||
STORAGE_ROOT='"${STORAGE_ROOT}"' | ||
PUBLIC_IP='"${PUBLIC_IP}"' | ||
PUBLIC_IPV6='"${PUBLIC_IPV6}"' | ||
DISTRO='"${DISTRO}"' | ||
PRIVATE_IP='"${PRIVATE_IP}"'' | sudo -E tee /etc/yiimpserver.conf >/dev/null 2>&1 | ||
|
||
sudo cp -r ~/yiimpserver /home/${yiimpadmin}/ | ||
cd ~ | ||
sudo setfacl -m u:${yiimpadmin}:rwx /home/${yiimpadmin}/yiimpserver | ||
sudo rm -r $HOME/yiimpserver | ||
clear | ||
echo "New User is installed..." | ||
echo -e "$RED Please reboot system and log in as the new user and type$COL_RESET $GREEN yiimpserver$COL_RESET $RED to continue setup...$COL_RESET" | ||
exit 0;; | ||
|
||
1) | ||
|
||
clear | ||
bash $(basename $0) && exit;; | ||
|
||
255) | ||
|
||
;; | ||
esac |
Oops, something went wrong.