DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD Packages and Ports

OpenBSD Packages and Ports Installation and upgrading of packages and ports on OpenBSD.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 18th September 2017
mefisto mefisto is offline
Port Guard
 
Join Date: Sep 2017
Posts: 20
Default First few, of probably many more, questions

Greetings all,

this is my second foray into OpenBSD land. Although not as easy to install as advertised, namely because of my insistence on setting the system the way I wanted to including dual boot with Windows, with some searching I managed. Amazingly, every feature I tested so far works.

Some of the searches led me to this forum, and after observing for a while, I subscribed.

One of the features I miss from ZFS is snapshots. Since I was unable to find any tool, I decided to write a script based on Mark Rubel's work at http://www.mikerubel.org/computers/rsync_snapshots/. Since this were to be my first script, I decided to stand on the shoulders of giants, i.e., steal from others. This did not turn so well since most of the script use bash, which is absent from base OpenBSD. Although I managed to find some tutorials on ksh to write the script, I wonder if this is the best way forward for portability reasons. Hence the first question:

1. What to do about scripts? Install bash for scripts? Or sacrifice portability and learn ksh?

Then the second problem arose. OpenBSD does not appear to have an /opt directory, hence the second question:

2. Where to store scripts and supporting files, e.g., configuration needed by the script?

Finally, since this is my first script, would someone be willing to look over it, to check for obvious errors and other clumsiness?

Kindest regards,

M
Attached Files
File Type: txt snapshot.txt (2.8 KB, 43 views)
Reply With Quote
  #2   (View Single Post)  
Old 18th September 2017
puffymon puffymon is offline
Real Name: Leonid
Port Guard
 
Join Date: Apr 2017
Location: Earth
Posts: 30
Default

1. If you want, install bash, if you want, learn sh (or ksh).
2. If you want /opt directory, just create it (or even create a partition and mount it to /opt, but you'll have to change some settings if you're going to install third-party software there), otherwise look at /usr/local/, it has everything from installed packages.
__________________
$ uname -a
OpenBSD puffy.pc 6.2 GENERIC.MP#146 amd64
$
Reply With Quote
  #3   (View Single Post)  
Old 18th September 2017
ibara's Avatar
ibara ibara is offline
WR Slowest SNOBOL4 laptop
 
Join Date: Jan 2014
Posts: 515
Default

Quote:
Originally Posted by mefisto View Post
I decided to write a script based on Mark Rubel's work at http://www.mikerubel.org/computers/rsync_snapshots/. Since this were to be my first script, I decided to stand on the shoulders of giants, i.e., steal from others. This did not turn so well since most of the script use bash, which is absent from base OpenBSD.
No it doesn't. There are almost no bash-isms (or, at least, no bash-isms that weren't originally ksh-isms) in the original script.

Quote:
Originally Posted by mefisto View Post
Although I managed to find some tutorials on ksh to write the script, I wonder if this is the best way forward for portability reasons.
If you care about maximum portability, you would write your script entirely in POSIX sh.

Quote:
Originally Posted by mefisto View Post
1. What to do about scripts? Install bash for scripts? Or sacrifice portability and learn ksh?
Learn POSIX sh and only use that. Or
Code:
# pkg_add bash
and don't worry about it.

Quote:
Originally Posted by mefisto View Post
2. Where to store scripts and supporting files, e.g., configuration needed by the script?
Where ever you want? Your $HOME? /etc? Make an /opt directory yourself?
Reply With Quote
  #4   (View Single Post)  
Old 18th September 2017
TronDD TronDD is offline
Package Pilot
 
Join Date: Sep 2014
Posts: 155
Default

I would use /bin/sh, that's the most portable. Most of the time, scripts start with /bin/bash because that's mostly what linux users know. They often don't actually use anything bash specific. Don't use ksh unless you need something more than what sh provides.

I put everything under /usr/local since the system doesn't touch anything there on upgrades.

For "snapshots", I recommend sysutils/borgbackup as it does incremental backups and deduplication. Saves a ton of space and you can go back in time for an older version of a file.
Reply With Quote
  #5   (View Single Post)  
Old 19th September 2017
mefisto mefisto is offline
Port Guard
 
Join Date: Sep 2017
Posts: 20
Default

Greetings all,

thank you for your replies.

I like the idea of using the /bin/sh for the scripts, due to the portability.

I also like the idea of using /usr/local, but as I checked HIER(7), it states that the /usr/local is used for "Local executables, libraries, etc." so since the system installs some of them, e.g., packages, thus potentially overwriting changes during upgrades.

Hi TronDD,

thank you for the sysutils/borgbackup recommendation, I will check whether it allows for some of the peculiar requirements that I have.

Kindest regards,

M
Reply With Quote
  #6   (View Single Post)  
Old 19th September 2017
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 5,944
Default

Executable programs and scripts from packages may be installed in /usr/local/bin, /usr/local/sbin, and /usr/local/libexec. I store local un-packaged scripts in these directories also, because the package tools pkg_add(1) and pkg_delete(1) will inform me of any conflicts. I store personal scripts in /home/<user>/bin.

I will admit to storing the occasional superuser script in /root on some of my servers, but I should consider moving those to /usr/local/sbin.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Two PF questions sparker OpenBSD Security 5 9th November 2009 08:01 AM
Some Questions ?? ultranothing OpenBSD Security 6 4th September 2009 04:59 PM
Questions about BSD (in general) fbsduser FreeBSD General 16 21st January 2009 02:41 PM
FTP ruleset questions hitete OpenBSD Security 2 25th November 2008 05:30 PM
A few questions on OpenBSD? php111 OpenBSD General 24 1st November 2008 09:18 AM


All times are GMT. The time now is 12:17 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick