Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Help with Creating a script (Leap)

  1. #1
    Join Date
    Dec 2011
    Location
    Chicago, IL
    Posts
    7

    Question Help with Creating a script (Leap)

    Hello all! I have been trying to create several scripts to just make things easier for starting my VPN and other services yet I can only get part of it working and still have to type in the rest and google isn't helping as the examples I can find are basically just how to make the terminal say "Hello". Here is the commands that I need to run to start my vpn (the simplest one I want to make a script for) or for scripts I have no clue what they are for and programs I don't use.

    This is what I do to start my VPN (Where it says "root password" "user" "password" its my root password, username for vpn, and password for vpn service.)

    Code:
    cd /etc/openvpn/
    sudo openvpn 'US East.ovpn'
    root password
    username
    password
    The farthest I can get with the script from using kwrite (and then changing the the permissions) is that I get asked for the root password, type it in, openvpn will start and then I have to type in the username, and password. I don't mind having to type in the root password but the username and password for the VPN service is randomly generated and I can never remember it and I would like to have the script enter in those itself.

    If I can get this working from seeing how it should be done I should be able to do the other 3 scripts myself, I have tried various ways doing it using ;. &&, echo, separate lines, nothing is working I just need an example.

    Thank you for your time!

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,300
    Blog Entries
    2

    Default Re: Help with Creating a script (Leap)

    I can propose something for everything except the username and password, you'll have to provide information how those are generated since you say those are randomly generated.

    It'd be useful to know at least whether those are stored as variables which are accessibly by script, and if you don't know that at least what is being used to generate those values and how you know them.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  3. #3
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    2,559

    Default Re: Help with Creating a script (Leap)

    Quote Originally Posted by scbbc81 View Post
    I have been trying to create several scripts to just make things easier for starting my VPN and other services
    Assuming that you are using a GUI and it's something that supports the "Network Manager" ("KDE Plasma 5" or "Gnome") with either KWallet or the Gnome Keyring configured then, from the Network Manager Connection Editor set-up a new connection using the choice "OpenVPN". Alternatively, the NM Config Editor does offer the possibility to "Import VPN" (File Menu).
    KWallet or Keyring are the preferred method(s) to store passwords and other data related to network connections.

  4. #4
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,300
    Blog Entries
    2

    Default Re: Help with Creating a script (Leap)

    Quote Originally Posted by tsu2 View Post
    I can propose something for everything except the username and password, you'll have to provide information how those are generated since you say those are randomly generated.

    It'd be useful to know at least whether those are stored as variables which are accessibly by script, and if you don't know that at least what is being used to generate those values and how you know them.

    TSU
    Occurred to me,
    Are you mixing up terminology?
    Username/passwords are usually known and stay the same once issued.
    Ephemeral certificates are typically created on demand to encrypt a connection, these of course cannot be static or they would be broken easily.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  5. #5
    Join Date
    Dec 2011
    Location
    Chicago, IL
    Posts
    7

    Default Re: Help with Creating a script (Leap)

    Sorry for the confusion I meant the username and password was generated upon signup, it doesn't change everytime, it's just random letters and numbers that i keep in a txt file to look at it and type it in when I need to. It's always the same. Also no GUI just using terminal most of the time, my work requires a vpn. If you must know it's private internet access which is one of their approved vpn's.

  6. #6
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    2,559

    Default Re: Help with Creating a script (Leap)

    Quote Originally Posted by scbbc81 View Post
    Also no GUI just using terminal most of the time, my work requires a vpn.
    You could take a look at "wicked"; and I'm making an assumption here that the system uses systemd for booting.
    In the "wicked" documentation in the 'samples/wicked' directory there's an example .xml for openVPN.
    Also, take a look at the openSUSE Wicked Portal: <https://en.opensuse.org/Portal:Wicked>

  7. #7
    Join Date
    Dec 2011
    Location
    Chicago, IL
    Posts
    7

    Default Re: Help with Creating a script (Leap)

    Quote Originally Posted by dcurtisfra View Post
    You could take a look at "wicked"; and I'm making an assumption here that the system uses systemd for booting.
    In the "wicked" documentation in the 'samples/wicked' directory there's an example .xml for openVPN.
    Also, take a look at the openSUSE Wicked Portal: <https://en.opensuse.org/Portal:Wicked>
    The problem is I want to learn. and Openvpn is just the simplest script I want to write once I see that and how scripts work I can make one for ffmpeg and other things. I will look into that though for openvpn though. Thank you.

  8. #8
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    2,559

    Default Re: Help with Creating a script (Leap)

    Quote Originally Posted by scbbc81 View Post
    The problem is I want to learn. and Openvpn is just the simplest script I want to write once I see that and how scripts work I can make one for ffmpeg and other things.
    OK. [Leaning a long way out of the window and putting my foot in my mouth.] IMHO this is possibly not a bad place to learn about scripts and the gentle art of scripting.
    • Be aware that writing and using scripts is a method to do system "things" without having to dive into the deep and complicated world of system programming.
    • Script languages: there are an awful amount of them . . .
    • The following *NIX CLI Shells all have an associated script language: C-Shell, Bourne-Shell, Korn-Shell, Bash.
    • There are also "pure" scripting languages (AFAIK no one has to date bothered to use them for a CLI) such as: Perl, Ruby, JavaScript, Tcl, et al.
    • In all cases, try to develop a logical and consistent scripting style: for example Shell scripts should always have the following as the first line (Bash example):

    #!/bin/bash

    • If you need to use variables in your script, define them early, clearly and concisely (also a Bash example):

    netnode=$(hostname)
    user=$(whoami)

    • Place comments in your script to ensure that the script can be clearly understood (yet another Bash example):

    #
    # Cannot use -a --archive: both imply -rlptgoD
    # -g --group "preserve group" is not supported by a WD MyBookWorld.
    #
    # Add --inplace after --stats if there are directories with the "sticky" bit set . . .
    # Usually add --inplace after --stats if really large files (databases) need to be cloned.
    #

    • In many cases it is nice to inform the user that something has happened (Bash again):

    echo '** Finished!!'

  9. #9
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    2,559

    Default Re: Help with Creating a script (Leap)

    Returning to the root password issue:
    You could run your script by invoking it via 'sudo'. The following URL is a reasonable tutorial for setting-up 'sudo': <https://wiki.archlinux.org/index.php/sudo>

  10. #10
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,300
    Blog Entries
    2

    Default Re: Help with Creating a script (Leap)

    I wan't planning on an official announce yet,
    But I've been compiling some interesting scriptlet code I've used in the past to do some things.
    Each example illustrates different BASH scripting concepts.

    They start on this page.
    Because this is not an an official announcement, it's all very rough and will likely undergo complete transformations periodically until I settle on at least a presentation format.

    https://en.opensuse.org/User:Tsu2/Scripts_and_Scriplets

    Currently, it contains working examples for...
    Creating your first BASH script and a link to Shell Check to debug your scripting
    Auto-detecting your OS and/or your openSUSE distro version so you can tailor code for the installed system.
    Various zypper unattended installs
    Configure MySQL/MariaDB Secure setup in one command
    Disable the common virtualization "dbus" error

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •