vaido-world / 7daystodie-live-server

Server Configurations and Mods currently active on 7dtd.vaido.world GameServer
https://github.com/vaido-world/7daystodie-dedicated-server
1 stars 0 forks source link

github payload #1

Open BoQsc opened 4 years ago

BoQsc commented 4 years ago
<?php

/*

rm 'test8.txt\r' 2>&1
chmod 777 vavazz
chown text9.txt;

chgrp www-data .git/FETCH_HEAD
chgrp www-data .git
usermod -a -G root www-data
usermod -a -G steam www-data
chmod -R 0775 7dtd
*/

// Use in the “Post-Receive URLs” section of your GitHub repo.
$output = shell_exec("pwd; cd /home/steam/; who; groups 2>&1; pwd ;whoami;ls -lart");
echo "<pre>$output</pre>";
echo "&lt;label&gt; AAAAA";

if ( $_POST['payload'] ) {
//shell_exec( "cd /home/steam/.steam/steamcmd/7dtd/; git reset –hard HEAD; git pull");
echo shell_exec( "cd /home/steam/.steam/steamcmd/7dtd/; git reset; git pull origin master 2>&1");

}

?>hissdfs

Recent version

<?php

/*

rm 'test8.txt\r' 2>&1
chmod 777 vavazz
chown text9.txt;

chgrp www-data .git/FETCH_HEAD
chgrp www-data .git
usermod -a -G root www-data
usermod -a -G steam www-data
chmod -R 0777 7dtd
*/

// Use in the “Post-Receive URLs” section of your GitHub repo.
$output = shell_exec("pwd; cd /home/steam/; who; groups 2>&1; pwd ;whoami;ls -lart");
echo "<pre>$output</pre>";
echo "&lt;label&gt; AAAAA";

echo shell_exec( "cd /home/steam/.steam/steamcmd/7dtd/ 2>&1;pwd; git reset; git pull origin master 2>&1");

if ( $_POST['payload'] ) {
shell_exec( "cd /home/steam/.steam/steamcmd/7dtd/; git reset –hard HEAD; git pull");
}

?>hissdfs
BoQsc commented 4 years ago

https://www.jobsity.com/blog/automatic-pull-server

BoQsc commented 4 years ago

7 Days To Die Prelaunch


[ "$(whoami)" = "steam" ] && ( 
    cp "/home/steam/.steam/steamcmd/7dtd/serverconfig.xml" "/home/steam/.steam/steamcmd/7dtd/executable_serverconfig.xml"
    xmlstarlet edit --inplace \
        --update "//property[@name='ServerPassword']/@value" \
        --value "" /home/steam/.steam/steamcmd/7dtd/executable_serverconfig.xml

    xmlstarlet edit --inplace \
        --update "//property[@name='ControlPanelEnabled']/@value" \
        --value "true" /home/steam/.steam/steamcmd/7dtd/executable_serverconfig.xml

    xmlstarlet edit --inplace \
        --update "//property[@name='ControlPanelPassword']/@value" \
        --value "hahaha" /home/steam/.steam/steamcmd/7dtd/executable_serverconfig.xml

    xmlstarlet edit --inplace \
        --update "//property[@name='TelnetEnabled']/@value" \
        --value "true" /home/steam/.steam/steamcmd/7dtd/executable_serverconfig.xml

    xmlstarlet edit --inplace \
        --update "//property[@name='TelnetPort']/@value" \
        --value "8081" /home/steam/.steam/steamcmd/7dtd/executable_serverconfig.xml

    xmlstarlet edit --inplace \
        --update "//property[@name='TelnetPassword']/@value" \
        --value "hahaha" /home/steam/.steam/steamcmd/7dtd/executable_serverconfig.xml

    /home/steam/.steam/steamcmd/7dtd/startserver.sh "executable_serverconfig.xml"
    rm /home/steam/.steam/steamcmd/7dtd/executable_serverconfig.xml

) || (
    echo Switch to linux user named "steam" to execute this script. (Use command: su steam)
)

xmlstarlet select -t -v \
    "//property[@name="ControlPanelEnabled"]/@name" --nl /home/steam/.steam/steamcmd/7dtd/serverconfig.xml

ControlPanelEnabled="$(xmlstarlet select --template \
    --value-of '//property[@name="ControlPanelEnabled"]/@value' \
    --nl /home/steam/.steam/steamcmd/7dtd/executable_serverconfig.xml)"

ControlPanelPassword="$(xmlstarlet select --template \
    --value-of '//property[@name="ControlPanelPassword"]/@value' \
    --nl /home/steam/.steam/steamcmd/7dtd/executable_serverconfig.xml)"

xmlstarlet sel -t -v \
'//property[@name="SaveGameFolder"]/@name' -n /home/steam/.steam/steamcmd/7dtd/serverconfig.xml

xmlstarlet sel -t -v \
'//property[@name="ServerName"]/@value' -n /home/steam/.steam/steamcmd/7dtd/serverconfig.xml

sed -i -e 's/abc/XYZ/g' 

cp /home/steam/.steam/steamcmd/7dtd/
BoQsc commented 4 years ago

New game Version load to repository

apt-get update
sudo apt install git
git init /home/steam/.steam/steamcmd/7dtd/

git push origin master

git config --list

git init
git add .
sudo git commit -m "initial commit"

protocol=https
host=https://github.com/vaido-world/
path=7daystodie-live-server.git
username=boqsc
password=leoreliuc1793

git credential fill < teee.txt

git remote show origin
git config --get remote.origin.url

sudo git checkout -b master
sudo git push origin master

sudo rm -rf .git
sudo git init
# Https login
git remote add origin https://github.com/vaido-world/7daystodie-live-server.git
git push origin master
# error: src refspec master does not match any.
sudo git add serverconfig.xml
git commit -m initial
git push origin master
#  Updates were rejected because the tip of your current branch is behind
git push origin master -f
# add more files
sudo git add .
sudo git commit -m "next"
sudo git push origin master -f

git status
sudo git add serverconfig.xml
sudo git pull --rebase
sudo git push --set-upstream origin master

git add .
git commit -m initial

git config --global user.name "BoQsc"
git config --global user.email "vaidas.boqsc@gmail.com"

sudo git remote set-url origin https://github.com/vaido-world/7daystodie-live-server.git

git push -u origin master

sudo git rm -r --cached .

git status --short
git reset -- README

sudo git reset
sudo git rm -rf --cached .
sudo git add .
sudo git commit -m initial

git remote set-url origin git@hostname:USERNAME/REPOSITORY.git.
sudo git remote set-url origin git@github.com:vaido-world/7daystodie-live-server.git
BoQsc commented 4 years ago

Candidates of Description

[EU][Alpha 19][PVP][24/7][Small Map]Survival Public Open Dedicated Server
A Dedicated server features:
Long-term perspective | Hosting till 2024
New start on every Major Game Update.
Community Support through Github Suggestions.
Downloadable Map Backups.
Simple Gameplay.

Lightweight Server-side modlets.

Owner: Random Guy from Europe
Contacts: vaidas.boqsc@gmail.com
Visit website for more.

Contributors friendly
From Europe With love.

No Moderators.
No Moderation.
Unlimited Gameplay.

Wipe on every Major Game Update.
Fresh start on every Major Game Update

[Randomly Generated Map]
Small Map
Tiny Map
Little Map

donate.vaido.world

Server AutoUpdate.

Please Donate.
Free For All
until 2024
For 4 years

Default Server Settings
BoQsc commented 4 years ago

7dtd/.gitignore File

Data/*
7DaysToDieServer_Data/*
Saves/*
BoQsc commented 4 years ago

Description Candidate

Facts:
    The Small Map is Generated. Not a Navegaze.
    PVPVE - Player Versus Player Versus Environment Server.
    Hosted for at least 4 years or more.   
    Freedom and minor moderation.
    Open community server with open configurations repository
    Open for Community Mod/configuration contributions
    Downloadable Map Backups.
    Minor server-side Mods.

Welcome 7 Days To Die Players,
I'm here to announce a small survival public community server for everyone.
The dedicated server is based in Europe, Lithuania and focused on European players.
It is a PVP/PVE server, so expect to be annoyed by getting shot and looted.
Indeed, not very a friendly server with little moderation and lots of freedom.
Game Time Resets to 20 days every three real life months. 
Game World and all the progress is being reset at every major Game Update like Alpha 18, Alpha 19, Alpha 20...'
That's it.
Welcome to the Vanilla Wasteland.

IP: 7days.vaido.world

More information on the server:
Server Configuration Repository: 
Server 

Game Seed: 

Feel free to donate, to expand and extend the gameplay.
Donate, if you care about people giving effort to make this server happen.
Some part of donations might be directly randomly given to the volunteers on the server's repository.
donate.vaido.world

Current Server Configurations:

Hosting is 

7 Days To Die Game Version: Alpha 19

Expected players

[System specification]
CPU: 
Memory: 4gb RAM
Storage: 40gb SSD
Bandwidth: 

Nuoma 
Professionally hosted by Hostinger.

This is a public community dedicated server
BoQsc commented 4 years ago

Setup Github connection

  1. Go to Profile settings
  2. Open Developer settings Tab
  3. Select Personal access tokens Tab
  4. Press Generate New Token Button
  5. Fill a Note field for the Token
  6. Select/tick repo Access Scope
  7. Click Button Generate token
  8. Copy the Personal Access Token
    Personal Access Token example: 53ddb88e918cb6775cd649c9bfe11e507b0b8057
  9. Use Personal Access Token instead of Password.
    Usage Form: sudo git remote set-url origin https://username:password@repository-url.com
    Example:
    sudo git remote set-url origin https://boqsc:53ddb88e918cb6775cd649c9bfe11e507b0b8057@github.com/vaido- 
    world/7daystodie-live-server.git

More information:

https://stackoverflow.com/questions/11403407/git-asks-for-username-every-time-i-push/21216107#21216107

BoQsc commented 4 years ago

Setup git push to Github Repository

# Install git client and setup local repository
sudo apt install git -y
cd /home/steam/.steam/steamcmd/7dtd/
git init
sudo git remote set-url origin https://boqsc:f80ea0344265617d5db2e72313101883f408196b@github.com/vaido-world/7daystodie-live-server.git

# .gitignore folders and files
echo "Data/*
7DaysToDieServer_Data/*
Saves/*
executable_serverconfig.xml
" > .gitignore

# Do a push to the Github Repository
sudo git add .
git commit -m initial
git push origin master -f
BoQsc commented 4 years ago

Setup automatic git pull from Github Repository

Add Webhook for the Github repository

  1. Open Repository Settings
  2. Click on Webhooks Tab
  3. Click Add webhook Button
  4. Fill a Payload URL with http://7days.vaido.world/github_payload.php
  5. Select Content Type as application/x-www-form-urlencoded
  6. Leave the Secret Field Empty
  7. Set radio-button of Which events would you like to trigger this webhook? to Just the push event.
  8. Tick the Active field
  9. Press Button Add Webhook

Server-side Github Payload Handle

# Install Apache2 and PHP
sudo apt-get install apache2 -y
sudo apt-get install php -y

# Setup Github Payload Handle

sudo bash -c '
cat <<"EOF" > /var/www/github_payload.php
<?php
if ( $_POST['payload'] ) {
    shell_exec( "cd /home/steam/.steam/steamcmd/7dtd/; git reset --hard HEAD; git stash push --include-untracked; git pull");

}

?>Github Handle Script loaded without errors
EOF'

# Setup Permissions for the PHP command line user named "www-data".
chgrp www-data /home/steam/.steam/steamcmd/7dtd/.git/FETCH_HEAD
chgrp www-data /home/steam/.steam/steamcmd/7dtd/.git

chmod -R 0777 /home/steam/.steam/steamcmd/7dtd/
chmod -R 0777 /home/steam/.steam/steamcmd/7dtd/.git
BoQsc commented 3 years ago

Schedule a server restart after git pull:

    • [x] Start the server with a named screen window
    • [ ] git pull
        • [ ] Send command of message announcment via telnet to the 7 Days To Die Game Server
        • [ ] Check if the timer to restart the server has not been started yet.
        • [ ] Wait for some amount of time.
        • [ ] Send command to shutdown the 7 Days To Die Game Server.
        • [ ] Wait for the server to shutdown
        • [ ] Kill the named screen window after game server shutdown.
        • [ ] Start the game server with a named screen window

Starting named screen session and terminating

screen -list
screen -S "7DaysToDie_GameServer"
screen -list
screen -X -S "7DaysToDie_GameServer" quit
screen -list

Broadcasting message in the Game Server using telnet

exec 3<>"/dev/tcp/localhost/8081"
echo 'say "[f9caa7]Checking the say command in the game server"' >&3
echo 'say "[f9caa7]An update to this server has been proposed and merged."' >&3
echo 'say "[f9caa7]This public server is about to be restarted in 10 minutes"' >/dev/tcp/localhost/8081

cat <&3

Delay Bash command from running for 5 seconds

sleep 5

Launching the server

https://github.com/vaido-world/7daystodie-dedicated-server/blob/63f792a69b3342b2324e35406e7eececa530616c/linux-rewrite-update.bash#L236-L237

BoQsc commented 3 years ago

When creating a new Game Server from scratch, on a new Game update.

  1. Change branch master to a branch with a date/time like 2020-07-14
  2. Create and Push the new server files to the master branch
BoQsc commented 3 years ago


screen -d -m "/home/steam/.steam/steamcmd/7dtd/startserver.sh" -configfile="serverconfig.xml"
-d (detach) Start screen in "detached" mode. This creates a new session but doesn't attach to it.
-m (enforced creation) Creation of a new session is enforced, regardless whether screen is called from within another screen session or not.
"/home/steam/.steam/steamcmd/7dtd/startserver.sh" -configfile="serverconfig.xml The executable script to run in the new `screen` session.

screen -d -m "/home/steam/.steam/steamcmd/7dtd/startserver.sh" -configfile="serverconfig.xml"
-d (detach)
Start screen in "detached" mode. This creates a new session but doesn't attach to it.
-m (enforced creation)
Creation of a new session is enforced, regardless whether screen is called from within another screen session or not.
"/home/steam/.steam/steamcmd/7dtd/startserver.sh" -configfile="serverconfig.xml
The executable script to run in the new `screen` session.
BoQsc commented 3 years ago

function checkIfShutdownAlreadyPlanned(){
    lastTimePlannedShutdown=$(</var/tmp/date-for-7dtd-restart-check);
    currentTime=$(date +%H:%M);
    if [[ "$lastTimePlannedShutdown" < "$currentTime" ]];
    then
      echo "$(date -d "$currentTime 10 minutes" +'%H:%M')" > /var/tmp/date-for-7dtd-restart-check
    else
      (echo 'say "[f9caa7]Community update: additional update has been proposed and soon to be integrated"')>&3
      return 1;
    fi
}
checkIfShutdownAlreadyPlanned;
echo $? here

if [[ "$?" != "1"]];
then

    # The bug seems to be resolved by adding delay between commands

    sleep 1;
    (echo 'say "[f9caa7]Community update here and now please wait asdasd  asdasd "')>&3
    sleep 1;
    (echo 'say "[f9caa7]Restart will happen in 10 minutes."' )>&3
    sleep 600;
    (echo 'say "[f9caa7]Restart will happen in 1 minute."' )>&3
    sleep 30;
    (echo 'say "[f9caa7]Restart will happen in 30 seconds."' )>&3
    sleep 20;
    (echo 'say "[f9caa7]Restart will happen in 10 seconds."' )>&3
    sleep 1;
    (echo 'say "[f9caa7]Restart will happen in 9 seconds."' )>&3
    sleep 1;
    (echo 'say "[f9caa7]Restart will happen in 8 seconds."' )>&3
    sleep 1;
    (echo 'say "[f9caa7]Restart will happen in 7 seconds."' )>&3
    sleep 1;
    (echo 'say "[f9caa7]Restart will happen in 6 seconds."' )>&3
    sleep 1;
    (echo 'say "[f9caa7]Restart will happen in 5 seconds."' )>&3
    sleep 1;
    (echo 'say "[f9caa7]Restart will happen in 4 seconds."' )>&3
    sleep 1;
    (echo 'say "[f9caa7]Restart will happen in 3 seconds."' )>&3
    sleep 1;
    (echo 'say "[f9caa7]Restart will happen in 2 seconds."' )>&3
    sleep 1;
    (echo 'say "[f9caa7]Restart will happen in 1 seconds."' )>&3
    sleep 1;
    (echo 'say "[f9caa7]Restarting the server for Community update."' )>&3
    sleep 1;
    (echo 'shutdown')>&3
    sleep 5;
    screen -X -S "7DaysToDie_GameServer" quit
    sleep 2;

    su - steam <<-'EOF1'
    cp "/home/steam/.steam/steamcmd/7dtd/serverconfig.xml" "/home/steam/.steam/steamcmd/7dtd/secure_serverconfig.xml"
        xmlstarlet edit --inplace \
            --update "//property[@name='ControlPanelEnabled']/@value" \
            --value "true" /home/steam/.steam/steamcmd/7dtd/secure_serverconfig.xml
        xmlstarlet edit --inplace \
            --update "//property[@name='ControlPanelPassword']/@value" \
            --value "hahaha" /home/steam/.steam/steamcmd/7dtd/secure_serverconfig.xml
        xmlstarlet edit --inplace \
            --update "//property[@name='TelnetEnabled']/@value" \
            --value "true" /home/steam/.steam/steamcmd/7dtd/secure_serverconfig.xml
        xmlstarlet edit --inplace \
            --update "//property[@name='TelnetPort']/@value" \
            --value "8081" /home/steam/.steam/steamcmd/7dtd/secure_serverconfig.xml
        xmlstarlet edit --inplace \
            --update "//property[@name='TelnetPassword']/@value" \
            --value "hahaha" /home/steam/.steam/steamcmd/7dtd/secure_serverconfig.xml
        screen -d -m -S "7DaysToDie_GameServer" "/home/steam/.steam/steamcmd/7dtd/startserver.sh" "-configfile=secure_serverconfig.xml"
    EOF1

fi