Editing
Rename vServer
From Linix VServer
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== General Administrative Tasks and System Tweaks == === Renaming a vServer === Suppose you want to rename your vserver (the directories not the hostname). This can be accomplished by renaming the config directory and the root for the vserver in question, then modifying 3 symlinks to match. 1. Stop the vserver in question 2. rename the /vservers/<server name> directory 3. rename the /etc/vservers/<server name> directory 4. update link: /etc/vservers/<server name>/run -> /var/run/vservers/<server name> 5. update link: /etc/vservers/<server name>/vdir -> /etc/vservers/.defaults/vdirbase/<server name> 6. update link: /etc/vservers/<server name>/cache -> /etc/vservers/.defaults/cachebase/<server name> 7. update link: /var/run/vservers.rev/<server XID> -> /etc/vservers/<server name> 8. Start the vserver in question. It should start properly. A script is provided below to help speed up the renaming process and reduce downtime by automating the sequence. Please make sure you verify the first 5 variables before running the script! === Sample vServer renaming bash script (wrote for Debian) === The script below does not create the dir/symlink for the cache dir - I will update it within the week. <pre> #!/bin/sh data_path="/data/vservers" config_path="/etc/vservers" run_path="/var/run/vservers" run_rev_path="/var/run/vservers.rev" vserver_exec="/usr/sbin/vserver" ### DO NOT CHANGE ANYTHING AFTER THIS LINE ### orig_dir=`pwd` function throwError { echo "" echo "-------------------------------" echo "Error: $error"; echo "-------------------------------" cd $orig_dir exit 0 } function checkExist { echo "" cd $data_path ls --color $data_path echo "" echo -n "What is the name of the vServer you wish to rename? : " read orig_name if [[ ! -d "$data_path/$orig_name" ]]; then checkExist fi } function newName { echo "" echo -n "What is the new name you would like? : " read new_name if [[ "$new_name" == "" ]]; then echo "Name supplied was empty" newName fi if [[ -d "$data_path/$new_name" ]]; then echo "Name already in use!" newName fi } function confirm { read u_confirm if [[ "$u_confirm" != "y" ]]; then error="Cancelled by user" throwError fi } echo "" echo "Data path: $data_path" echo "Config path: $config_path" echo "Run path: $run_path" echo "Run rev path: $run_rev_path" echo "vServer executable $vserver_exec" echo "" echo -n "Are these paths correct? y/N : " confirm checkExist newName # Check all the dirs and symlinks exist if [[ ! -d "$config_path/$orig_name" ]] || [[ "$orig_name" == "" ]]; then error="vServer config path doesn't exist" throwError fi # Grab the context for that vServer context=`cat $config_path/$orig_name/context` if [[ ! -d "$run_rev_path/$context" ]]; then error="vServer run rev path ($run_rev_path/$context) doesn't exist" throwError fi if [[ ! -f "$vserver_exec" ]]; then error="vServer exec file doesn't exist" throwError fi # Confirm before stopping vServer echo "" echo -n "Are you ready to start the renaming process? y/N : " confirm $vserver_exec $orig_name stop mv $data_path/$orig_name $data_path/$new_name mv $config_path/$orig_name $config_path/$new_name /bin/rm $config_path/$new_name/run ln -s $run_path/$new_name $config_path/$new_name/run /bin/rm $config_path/$new_name/vdir ln -s $config_path/.defaults/vdirbase/$new_name $config_path/$new_name/vdir /bin/rm $config_path/$new_name/cache ln -s $config_path/.defaults/cachebase/$new_name $config_path/$new_name/cache /bin/rm $run_rev_path/$context ln -s $config_path/$new_name $run_rev_path/$context $vserver_exec $new_name start cd $orig_dir </pre> [[Category:Documentation]] [[Category:Migration]]
Summary:
Please note that all contributions to Linix VServer may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Linix VServer:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Page actions
Page
Discussion
Read
Edit
History
Page actions
Page
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
About
Overview
Paper
News
Developers
Donations
Search
Getting Started
Downloads
FAQs
Documentation
Support
Participate
How to participate
Report a Bug
Communicate
Teams/Projects
Hall of Fame
Resources
Archives
Recent Wiki Changes
Pastebin
Related Projects
VServer Hosting
Happy VServer Users
Tools
What links here
Related changes
Special pages
Page information