Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simple-vm-manager
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
simple-vm-manager
Commits
15125cab
There was an error fetching the commit references. Please try again later.
Commit
15125cab
authored
1 year ago
by
Recolic
Browse files
Options
Downloads
Patches
Plain Diff
.bugfixes
parent
d6ad3e5c
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+7
-1
7 additions, 1 deletion
README.md
cron-callback.sh
+20
-18
20 additions, 18 deletions
cron-callback.sh
init.settings
+2
-2
2 additions, 2 deletions
init.settings
runtime.settings
+1
-1
1 addition, 1 deletion
runtime.settings
with
30 additions
and
22 deletions
README.md
+
7
−
1
View file @
15125cab
...
...
@@ -16,7 +16,9 @@ Turn your server/desktop to DigitalOcean / Linode / Vultr with a super-simple sc
qemu, bash, sed
> ArchLinux user: simply run `pacman -S cdrkit qemu-base`
Optional: aria2c (simply replace aria2c with curl if you don't like it)
> ArchLinux user: simply run `pacman -S cdrkit qemu-base aria2`
## Usage
...
...
@@ -24,6 +26,10 @@ qemu, bash, sed
2.
Modify
`init.settings`
and
`runtime.settings`
.
3.
Add
`*/2 * * * * cd /path/to/my/repo && ./cron-callback.sh`
into your crontab.
## Supported cloudimg
## FAQ
## My desired OS is not supported yet...
...
...
This diff is collapsed.
Click to expand it.
cron-callback.sh
+
20
−
18
View file @
15125cab
...
...
@@ -28,18 +28,22 @@ password: $password
chpasswd: { expire: False }
hostname:
$name
# configure sshd to allow users logging in using password
# rather than just keys
# allow password login
ssh_pwauth: True
"
}
function
download_cloud_img_if_not_exist
()
{
local
cloudimg
=
"
$1
"
[[
"
$1
"
!=
"focal-server-cloudimg-amd64.img"
]]
&&
echo2
"ERROR: cloudimg not supported"
[[
-f
"base/
$cloudimg
"
]]
&&
return
declare
-A
knowledge
knowledge[
"focal-server-cloudimg-amd64.img"
]=
https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
knowledge[
"Arch-Linux-x86_64-cloudimg.qcow2"
]=
https://geo.mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-cloudimg.qcow2
[
!
"
${
knowledge
[
$cloudimg
]+abc
}
"
]
&&
echo2
"Unknown cloudimg
$cloudimg
. cannot download it."
&&
return
1
echo2
"+ Downloading cloudimg
$cloudimg
..."
aria2c
-o
"base/
$cloudimg
"
https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
||
!
echo2
"Failed to download ubuntu cloudimg"
||
return
$?
aria2c
-o
"base/
$cloudimg
"
"
${
knowledge
[
$cloudimg
]
}
"
||
!
echo2
"Failed to download ubuntu cloudimg"
||
return
$?
}
function
create_vm_if_not_exist
()
{
...
...
@@ -50,20 +54,18 @@ function create_vm_if_not_exist () {
local
username
=
$4
local
password
=
"
$5
"
if
[[
-f
"vm/
$name
/disk.img"
]]
;
then
# already exists
:
else
download_cloud_img_if_not_exist
"
$cloudimg
"
||
return
$?
rm
-rf
"vm/
$name
"
;
mkdir
-p
"vm/
$name
"
# create it
echo2
"+ Creating VM image
$name
with options
$@
..."
generate_metadata
"
$name
"
>
"vm/
$name
/meta-data"
||
return
$?
generate_userdata
"
$username
"
"
$password
"
"
$name
"
>
"vm/
$name
/user-data"
||
return
$?
(
cd
"vm/
$name
"
;
genisoimage
-output
initimg.iso
-volid
cidata
-joliet
-rock
user-data meta-data
)
||
return
$?
qemu-img create
-f
qcow2
-F
qcow2
-o
backing_file
=
"../../base/focal-server-cloudimg-amd64.img"
"vm/
$name
/disk.img"
||
return
$?
qemu-img resize
"vm/
$name
/disk.img"
"
$disk
"
||
return
$?
fi
# Check if disk img already exists.
[[
-f
"vm/
$name
/disk.img"
]]
&&
return
download_cloud_img_if_not_exist
"
$cloudimg
"
||
return
$?
rm
-rf
"vm/
$name
"
;
mkdir
-p
"vm/
$name
"
# create it
echo2
"+ Creating VM image
$name
with options
$@
..."
generate_metadata
"
$name
"
>
"vm/
$name
/meta-data"
||
return
$?
generate_userdata
"
$username
"
"
$password
"
"
$name
"
>
"vm/
$name
/user-data"
||
return
$?
(
cd
"vm/
$name
"
;
genisoimage
-output
initimg.iso
-volid
cidata
-joliet
-rock
user-data meta-data
)
||
return
$?
qemu-img create
-f
qcow2
-F
qcow2
-o
backing_file
=
"../../base/
$cloudimg
"
"vm/
$name
/disk.img"
||
return
$?
qemu-img resize
"vm/
$name
/disk.img"
"
$disk
"
||
return
$?
}
function
start_vm_if_not_running
()
{
...
...
This diff is collapsed.
Click to expand it.
init.settings
+
2
−
2
View file @
15125cab
# name;cloudimg;disk;username;password (space will be trimmed)
instance1;focal-server-cloudimg-amd64.img;60G;r;1
#
gitlab-ci;
focal-server-cloudimg-amd64.img;6
0G;r;1
#httptest ;focal-server-cloudimg-amd64.img;
6
0G;r;1
gitlab-ci;
Arch-Linux-x86_64-cloudimg.qcow2;4
0G;r;1
#httptest ;focal-server-cloudimg-amd64.img;
2
0G;r;1
This diff is collapsed.
Click to expand it.
runtime.settings
+
1
−
1
View file @
15125cab
# name;options (name will be trimmed, options will be passed as-is)
instance1;-m 2G -smp 2 -vnc :11 -net user,hostfwd=tcp::30471-:22
#
gitlab-ci;-m 4G -smp 4 -vnc :12 -net user,hostfwd=tcp::30473-:22
gitlab-ci;-m 4G -smp 4 -vnc :12 -net user,hostfwd=tcp::30473-:22
#httptest ;-m 1G -smp 1 -vnc :13 -net user,hostfwd=tcp::30474-:22
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment