From e340d2a6219f25904e79ebb5524b65e8fc65e956 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Sat, 22 Nov 2008 20:41:18 -0600
Subject: backport from linhes

---
 abs/mv-core/MythVantage-config/PKGBUILD            |   5 +-
 .../MythVantage-config/install_functions.sh        |   3 +-
 abs/mv-core/MythVantage-config/install_proxy.sh    |  22 ++-
 abs/mv-core/MythVantage-config/myth_user_call      | 164 +++++++++++++++++++++
 abs/mv-core/MythVantage-config/systemconfig.sh     |   1 +
 .../templates/remotes/receiver_usb.id              |  37 ++++-
 abs/mv-core/graphviz/PKGBUILD                      |   2 +-
 7 files changed, 225 insertions(+), 9 deletions(-)
 create mode 100644 abs/mv-core/MythVantage-config/myth_user_call

diff --git a/abs/mv-core/MythVantage-config/PKGBUILD b/abs/mv-core/MythVantage-config/PKGBUILD
index 619c755..dd3835b 100755
--- a/abs/mv-core/MythVantage-config/PKGBUILD
+++ b/abs/mv-core/MythVantage-config/PKGBUILD
@@ -1,10 +1,10 @@
 pkgname=MythVantage-config
 pkgver=3.2
-pkgrel=131
+pkgrel=134
 pkgdesc="The Gui-installer"
 depends=(bc mysql-python expect curl dnsutils sg3_utils parted)
 arch=('i686')
-source=(mythinstall.bin install-ui.xml  bpopup-ui.xml  mythbeselect.bin install_proxy.sh install_functions.sh startx systemconfig.sh install_db_chroot.sh restore_default_settings.sh live-install.sh xconfig.sh timezip.py soundconfig.sh mythvantage-release issue autocard.py MythVantage.sh create_master.sh build_diskless.sh networkconfig.sh )
+source=(mythinstall.bin install-ui.xml  bpopup-ui.xml  mythbeselect.bin install_proxy.sh install_functions.sh startx systemconfig.sh install_db_chroot.sh restore_default_settings.sh live-install.sh xconfig.sh timezip.py soundconfig.sh mythvantage-release issue autocard.py MythVantage.sh create_master.sh build_diskless.sh networkconfig.sh myth_user_call )
 install=live.install
 build() {
 
@@ -25,6 +25,7 @@ build() {
 #copy in all the installer specific stuff
     #cp -rp ../templates $MVDIR/
     rsync -r --exclude=.svn ../templates $MVDIR/
+   install -m0700 myth_user_call  $MVDIR/bin/myth_user_call
     install -m 0755 install_proxy.sh  $MVDIR/bin/install_proxy.sh
     install -m 0755 install_functions.sh  $MVDIR/bin/install_functions.sh
     install -m 0755 systemconfig.sh  $MVDIR/bin/systemconfig.sh
diff --git a/abs/mv-core/MythVantage-config/install_functions.sh b/abs/mv-core/MythVantage-config/install_functions.sh
index cf247cb..84f9c94 100755
--- a/abs/mv-core/MythVantage-config/install_functions.sh
+++ b/abs/mv-core/MythVantage-config/install_functions.sh
@@ -60,7 +60,8 @@ do
     lsusb -d "$USBID" > /dev/null 2>/dev/null
     if [ $? = 0 ]
     then
-        Remotetype=`echo "$line"|cut -f2`
+       # Remotetype=`echo "$line"|cut -f2`
+	 Remotetype=`echo "$line"|cut -d"|" -f2`
         echo "found $Remotetype"
         setupremote
         break
diff --git a/abs/mv-core/MythVantage-config/install_proxy.sh b/abs/mv-core/MythVantage-config/install_proxy.sh
index 4f8e088..d0be6c3 100755
--- a/abs/mv-core/MythVantage-config/install_proxy.sh
+++ b/abs/mv-core/MythVantage-config/install_proxy.sh
@@ -31,6 +31,25 @@ fi
 
 }
 
+function apply_new_auth () {
+#check if file is present
+    if  [ -f  /root/myth_user_call.out ]
+    then
+        #read in file, running each command in chroot
+        exec 4</root/myth_user_call.out
+        while read LINE <&4
+        do
+            if [ ! x"$LINE" = x ]
+            then
+                #run commands in chroot
+                chroot "$mountpoint"   $MV_ROOT/bin/myth_user_call -i $LINE > /tmp/user_auth.update
+            fi
+        done
+        rm -f /root/myth_user_call.out
+    else
+        echo "No new password changes to apply"
+    fi
+}
 
 
 
@@ -87,7 +106,7 @@ full_install () {
         cp -f $MV_ROOT/bin/*.sh "$mountpoint"$MV_ROOT/bin/
         chmod -R 755 ${mountpoint}/root
         cp /etc/mtab "$mountpoint"/etc/mtab
-
+	apply_new_auth
 
     if  [ $SystemType = "Master_backend" -o $SystemType = "Standalone"  ]
     then
@@ -216,6 +235,7 @@ function upgrade () {
     #Run second time
         chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh misc,hostype,network,advanced,this_is_install
         chroot "$mountpoint" $MV_ROOT/bin/systemconfig.sh advanced,this_is_install
+	apply_new_auth
         umount "$mountpoint/dev"
         umount "$mountpoint/proc"
     echo "Done" > /tmp/.install_state
diff --git a/abs/mv-core/MythVantage-config/myth_user_call b/abs/mv-core/MythVantage-config/myth_user_call
new file mode 100644
index 0000000..d95e468
--- /dev/null
+++ b/abs/mv-core/MythVantage-config/myth_user_call
@@ -0,0 +1,164 @@
+#!/bin/bash
+#Wrapper script to manage USERNAME accounts + web security
+# myth_USERNAME_all -c add -u USERNAME
+# myth_USERNAME_all -c delete -u USERNAME
+# myth_USERNAME_all -c pass  -u USERNAME -p pass
+# myth_USERNAME_all -c web  -u USERNAME -p pass
+
+INIT_CHECK=TRUE
+FULL_CALL="$@"
+function CHROOT_CHECK {
+    INIT=`ps -p 1 -o comm=`
+    if [ x$INIT = xrunit ]
+    then
+       CHROOT_NEEDED=FALSE
+    else
+       CHROOT_NEEDED=TRUE
+    fi
+}
+
+function store_commands () {
+    echo "$FULL_CALL" >> /root/myth_user_call.out
+    chmod 600 /root/myth_user_call.out
+}
+
+
+function add_user() {
+    if [ $CHROOT_NEEDED = TRUE ]
+    then
+        echo "calling myth_call_user in chroot to add user"
+        store_commands
+    else
+        echo "adding user $USERNAME"
+	useradd -m -s /bin/bash $USERNAME -G audio,video,optical,storage,users
+    fi
+
+}
+
+
+function del_user() {
+    if [ $CHROOT_NEEDED = TRUE ]
+    then
+        echo "calling myth_call_user in chroot to delete user"
+        store_commands
+    else
+        echo "removing  user $USERNAME"
+        userdel $USERNAME
+    fi
+
+}
+
+
+function pass_change() {
+    if [ $CHROOT_NEEDED = TRUE ]
+    then
+        echo "calling myth_call_user in chroot to change password"
+        store_commands
+    else
+        echo "changing password for $USERNAME"
+        echo $USERNAME:$PASSWORD | chpasswd
+    fi
+
+}
+
+
+function web_security {
+    echo "this is just a stub"
+
+}
+
+function ARG_ERR()  {
+        if [  x$OPTARG = "x" ]
+        then
+            echo "$SWITCH NEEDS AND ARG"
+            exit 11
+        fi
+}
+
+
+function print_help {
+
+    echo "Valid options are:"
+    echo "  -c (add|delete|pass|web)"
+    echo "  -u  USERNAMEname"
+    echo "  -p  password"
+    exit 1
+}
+
+if [ $# -eq 0 ]
+then
+    print_help
+fi
+
+declare -r OPTSTRING="c:u:p:i"
+while getopts "$OPTSTRING"  SWITCH
+do
+    case $SWITCH in
+
+            c)  ARG_ERR
+                OPERATION=$OPTARG
+                ;;
+            u)  ARG_ERR
+                USERNAME=$OPTARG
+                ;;
+            p)  ARG_ERR
+                PASSWORD=$OPTARG
+                ;;
+            i)  INIT_CHECK=FALSE
+
+    esac
+done
+
+if [ $INIT_CHECK = TRUE ]
+then
+    CHROOT_CHECK
+else
+    CHROOT_NEEDED=FALSE
+fi
+
+case $OPERATION in
+    add)
+            if [ x$USERNAME = x ]
+            then
+                print_help
+            fi
+            add_user
+        ;;
+    delete)
+            if [ x$USERNAME = x ]
+            then
+                print_help
+            fi
+            del_user
+        ;;
+    pass)
+            if [ x$USERNAME = x ]
+            then
+                print_help
+            fi
+
+            if [ x$PASSWORD = x ]
+            then
+                print_help
+            fi
+            pass_change
+        ;;
+
+    web)
+            if [ x$USERNAME = x ]
+            then
+                print_help
+            fi
+
+
+            if [ x$PASSWORD = x ]
+            then
+                print_help
+            fi
+            echo "adding webUSERNAME $USERNAME with $PASS"
+            ;;
+    *)  print_help
+        ;;
+esac
+
+
diff --git a/abs/mv-core/MythVantage-config/systemconfig.sh b/abs/mv-core/MythVantage-config/systemconfig.sh
index 9ee69ac..a038286 100755
--- a/abs/mv-core/MythVantage-config/systemconfig.sh
+++ b/abs/mv-core/MythVantage-config/systemconfig.sh
@@ -31,6 +31,7 @@ if [ x$1 = x"Mysql_only" ]
 if [ -f /etc/systemconfig ]
 then
 	. /etc/systemconfig
+setup_MYTH_vars
 TEMPNET="Hostip"$default_interface
 echo $TEMPNET
 eval MYTHIP=\$${TEMPNET}
diff --git a/abs/mv-core/MythVantage-config/templates/remotes/receiver_usb.id b/abs/mv-core/MythVantage-config/templates/remotes/receiver_usb.id
index b99f91b..4070964 100644
--- a/abs/mv-core/MythVantage-config/templates/remotes/receiver_usb.id
+++ b/abs/mv-core/MythVantage-config/templates/remotes/receiver_usb.id
@@ -1,4 +1,33 @@
-0bc7:0005	snapstream_firefly	X10 Wireless Technology, Inc.
-0e9c:0000	streamzap	Streamzap, Inc. Streamzap Remote Control
-0471:0815	mceusb	Microsoft usb receiver_transmitter rc6
-	
+0bc7:0005|snapstream_firefly|    "X10 Wireless Technology, Inc."
+0bc7:0008|SnapStream_Firefly|    "SnapStream Firefly"
+10c4:0003|CommandIR_Tranceiver|     " CommandIR Transceiver"
+0bc7:0004|ATI_Remote_Wonder|    " ATI Remote Wonder"
+0e9c:0000|streamzap|    "Streamzap Remote"
+0fe9:9010|dvico|   "DVICO Remote:"
+6253:0100|Twinhan_USB|  "the VisionPlus is a Twinhan clone "
+1509:9242|MCEUSB-new|  "FIC eHome Infrared Transceiver 1509/9242"
+1934:0602|MCEUSB-new|  "Fintek eHome Infrared Transceiver 1934/0602"
+147a:e015|MCEUSB-new|  "Formosa eHome Infrared Transceiver 147a/e015"
+147a:e017|MCEUSB-new|  "Formosa aim / Trust MCE Infrared Receiver147a/e017"
+147a:e018|MCEUSB-new|  "Formosa Industrial Computing 147a/e018"
+107b:3009|MCEUSB-new|  "Gateway eHome Infrared Transceiver 107b/3009"
+195d:7002|MCEUSB-new|  "Itron ione Libra Q-11 195d/7002"
+043e:9803|MCEUSB-new|  "LG eHome Infrared Transceiver 043e/9803"
+045e:00a0|MCEUSB-new|  "Microsoft MCE Infrared Transceiver 045e/00a0"
+03ee:2501|MCEUSB-new|  "Mitsumi 03ee/2501"
+0471:060c|MCEUSB-new|  "Philips Infrared Transciever - HP branded 0471/060C"
+0471:060d|MCEUSB-new|  "Philips SRM5100 0471/060d"
+0471:0815|MCEUSB-new|  "Philips eHome Infrared Transciever 0471/0815"
+2304:0225|MCEUSB-new| "Pinnacle Systems, Inc. 2304/0225"
+179d:0010|MCEUSB-new|  "Ricavision internal Infrared Transceiver 179d/0010"
+1308:c001|MCEUSB-new|  "Shuttle eHome Infrared Transceiver 1308/c001"
+051c:c001|MCEUSB-new|  "Shuttle2 eHome Infrared Transceiver 051c/c001"
+0609:031d|MCEUSB-new|  "SMK/Toshiba G83C0004D410 0609/031d"
+0609:0322|MCEUSB-new|  "SMK eHome Infrared Transceiver (Sony VAIO)0609/0322"
+0609:0334|MCEUSB-new|  "SKM bundled with Hauppauge PVR-150 0609/0334"
+1460:9150|MCEUSB-new|  "Tatung eHome Infrared Transceiver 1460/9150"
+1784:0001|MCEUSB-new|  "Topseed eHome Infrared Transceiver 1784/0001"
+1784:0006|MCEUSB-new|  "Topseed HP eHome Infrared Transceiver 1784/0006"
+1784:0007|MCEUSB-new|  "Topseed HP eHome Infrared Transceiver 1784/0007"
+1784:0008|MCEUSB-new|  "Topseed eHome Infrared Transceiver 1784/0008"
+045e:006d|MCEUSB-old|  "USB Microsoft IR Transceiver Driver 045e/006d"
diff --git a/abs/mv-core/graphviz/PKGBUILD b/abs/mv-core/graphviz/PKGBUILD
index c979153..8f127b7 100644
--- a/abs/mv-core/graphviz/PKGBUILD
+++ b/abs/mv-core/graphviz/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=graphviz
 pkgver=2.20.2
-pkgrel=1
+pkgrel=2
 pkgdesc="Graph Visualization Software"
 arch=(i686)
 url="http://www.graphviz.org/About.php"
-- 
cgit v0.12