Skip to content

Commit

Permalink
added tap conf
Browse files Browse the repository at this point in the history
  • Loading branch information
simplebsd committed Jun 24, 2017
1 parent b5be57b commit 24492fb
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
38 changes: 32 additions & 6 deletions bsiinstall.cpp
@@ -1,6 +1,6 @@
void install() {
int os, cpu, mem, disk;
char iso[150], tap[100], name[100], com1[300], com2[300], folder[150], filename[150], uifilename[150], ifile[100], ufilename[150], sh_file[150], ush_file[300];
int os, cpu, mem, disk, t, nt;
char iso[150], tap[100], name[100], com1[300], com2[300], folder[150], filename[150], uifilename[150], ifile[100], ufilename[150], sh_file[150], ush_file[300], br[150];

cout << "OS:\n";
cout << "1. FreeBSD.\n";
Expand All @@ -10,6 +10,15 @@ void install() {
cout << "\n";

if(os == 1) {

ifstream tapr("/usr/local/etc/bsi/tap.conf");
tapr >> t;
tapr.close();

nt = t +1;

sprintf(tap, "tap%i", nt);

cout << "Enter full path for install iso: ";
cin >> iso;
cout << "\n";
Expand All @@ -22,8 +31,6 @@ void install() {
cout << "Enter size of disk(GB): ";
cin >> disk;
cout << "\n";
cout << "Enter tap device: ";
cin >> tap;
cout << "\n";
cout << "Enter name: ";
cin >> name;
Expand All @@ -42,9 +49,23 @@ void install() {
sprintf(com2, "/usr/share/examples/bhyve/vmrun.sh -c %i -m %i -t %s -d /usr/bsi/vm/%s/%s.img -i -I %s %s", cpu, mem, tap, name, name, iso, name);
system(com2);

ofstream tapw("/usr/local/etc/bsi/tap.conf");
tapw << nt;
tapw.close();

sprintf(br, "ifconfig tap%i create && ifconfig bridge addm tap%i up", nt, nt);
system(br);
}

else if(os == 2) {
ifstream tapr("/usr/local/etc/bsi/tap.conf");
tapr >> t;
tapr.close();

nt = t +1;

sprintf(tap, "tap%i", nt);

cout << "Enter full path for install iso: ";
cin >> iso;
cout << "\n";
Expand All @@ -57,8 +78,6 @@ void install() {
cout << "Enter size of disk(GB): ";
cin >> disk;
cout << "\n";
cout << "Enter tap device: ";
cin >> tap;
cout << "\n";
cout << "Enter name: ";
cin >> name;
Expand Down Expand Up @@ -87,5 +106,12 @@ void install() {
ush_file << "#!/bin/sh\nwhile [ 1 ]; do\nbhyvectl --destroy --vm=" << name << "\ngrub-bhyve -r hd0,msdos1 -m /usr/bsi/vm/" << name << "/device.map -M " << mem << " " << name << "\n\nbhyve -c " << cpu << " -m " << mem << " -H -P -A \\\n-l com1,stdio \\\n-s 0:0,hostbridge \\\n-s 1:0,lpc \\\n-s 2:0,virtio-net," << tap << " \\\n-s 4,virtio-blk,/usr/bsi/vm/" << name << "/" << name << ".img " << name << " \nbhyve_exit=$?\nif [$bhyve_exit -ne 0]; then\nbreak\nfi\ndone\nbhyvectl --destroy --vm=" << name << "\n";
ush_file.close();
chmod(ufilename, S_IRWXU|S_IXGRP|S_IXOTH);

ofstream tapw("/usr/local/etc/bsi/tap.conf");
tapw << nt;
tapw.close();

sprintf(br, "ifconfig tap%i create && ifconfig bridge addm tap%i up", nt, nt);
system(br);
}
}
2 changes: 2 additions & 0 deletions bsistart.cpp
@@ -1,3 +1,5 @@
using namespace std;

void start(char *vm) {
char com[100], path_img[100], path_vm[100];

Expand Down
2 changes: 2 additions & 0 deletions bsistop.cpp
@@ -1,3 +1,5 @@
using namespace std;

void stop(char *vm) {
char com[50], path_img[100], path_vm[100];

Expand Down
2 changes: 2 additions & 0 deletions tap_add.txt
@@ -0,0 +1,2 @@
sed -i '' '/^cloned_interfaces/s/$/ tap100/' /etc/rc.conf
sed -i '' '/^cloned_interfaces/s/.$//' /etc/rc.conf

0 comments on commit 24492fb

Please sign in to comment.